diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index 960a7c40f..74b6ab2f1 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -1,5 +1,6 @@ [defaults] inventory=inventory +interpreter_python=/usr/bin/python3 [ssh_connection] pipelining = True diff --git a/ansible/lemmy.yml b/ansible/lemmy.yml index bc01623fc..dcafc5eac 100644 --- a/ansible/lemmy.yml +++ b/ansible/lemmy.yml @@ -24,10 +24,11 @@ creates: '/etc/letsencrypt/live/{{domain}}/privkey.pem' - name: create lemmy folder - file: path={{item.path}} state=directory + file: path={{item.path}} {{item.owner}} state=directory with_items: - - { path: '/lemmy/' } - - { path: '/lemmy/volumes/' } + - { path: '/lemmy/', owner: 'root' } + - { path: '/lemmy/volumes/', owner: 'root' } + - { path: '/lemmy/volumes/pictrs/', owner: '991' } - block: - name: add template files @@ -38,9 +39,6 @@ - { src: '../docker/iframely.config.local.js', dest: '/lemmy/iframely.config.local.js', mode: '0600' } vars: lemmy_docker_image: "dessalines/lemmy:{{ lookup('file', 'VERSION') }}" - lemmy_port: "8536" - pictshare_port: "8537" - iframely_port: "8538" - name: add config file (only during initial setup) template: src='templates/config.hjson' dest='/lemmy/lemmy.hjson' mode='0600' force='no' owner='1000' group='1000' diff --git a/ansible/lemmy_dev.yml b/ansible/lemmy_dev.yml index e9b8364f3..05eb1ffed 100644 --- a/ansible/lemmy_dev.yml +++ b/ansible/lemmy_dev.yml @@ -26,10 +26,11 @@ creates: '/etc/letsencrypt/live/{{domain}}/privkey.pem' - name: create lemmy folder - file: path={{item.path}} state=directory + file: path={{item.path}} owner={{item.owner}} state=directory with_items: - - { path: '/lemmy/' } - - { path: '/lemmy/volumes/' } + - { path: '/lemmy/', owner: 'root' } + - { path: '/lemmy/volumes/', owner: 'root' } + - { path: '/lemmy/volumes/pictrs/', owner: '991' } - block: - name: add template files diff --git a/ansible/templates/docker-compose.yml b/ansible/templates/docker-compose.yml index 9ec1bfbc2..0b33399bd 100644 --- a/ansible/templates/docker-compose.yml +++ b/ansible/templates/docker-compose.yml @@ -12,7 +12,7 @@ services: - ./lemmy.hjson:/config/config.hjson:ro depends_on: - postgres - - pictshare + - pictrs - iframely postgres: @@ -25,18 +25,19 @@ services: - ./volumes/postgres:/var/lib/postgresql/data restart: always - pictshare: - image: hascheksolutions/pictshare:latest + pictrs: + image: asonix/pictrs:amd64-v0.1.0-r9 + user: 991:991 ports: - - "127.0.0.1:8537:80" + - "127.0.0.1:8537:8080" volumes: - - ./volumes/pictshare:/usr/share/nginx/html/data + - ./volumes/pictrs:/mnt restart: always iframely: image: dogbin/iframely:latest ports: - - "127.0.0.1:8061:80" + - "127.0.0.1:8538:80" volumes: - ./iframely.config.local.js:/iframely/config.local.js:ro restart: always diff --git a/ansible/templates/nginx.conf b/ansible/templates/nginx.conf index a978c1899..b96bbce7f 100644 --- a/ansible/templates/nginx.conf +++ b/ansible/templates/nginx.conf @@ -70,19 +70,15 @@ server { proxy_cache_min_uses 5; } - location /pictshare/ { + location /pictrs/ { proxy_pass http://0.0.0.0:8537/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - - if ($request_uri ~ \.(?:ico|gif|jpe?g|png|webp|bmp|mp4)$) { - add_header Cache-Control "public, max-age=31536000, immutable"; - } } location /iframely/ { - proxy_pass http://0.0.0.0:8061/; + proxy_pass http://0.0.0.0:8538/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index 1702f66d3..6c0624c4b 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -1,22 +1,22 @@ version: '3.3' services: - postgres: - image: postgres:12-alpine - environment: - - POSTGRES_USER=lemmy - - POSTGRES_PASSWORD=password - - POSTGRES_DB=lemmy + nginx: + image: nginx:1.19-alpine + ports: + - "8536:8536" volumes: - - ./volumes/postgres:/var/lib/postgresql/data - restart: always + - ./nginx.conf:/etc/nginx/nginx.conf + depends_on: + - lemmy + - pictrs + - iframely + restart: "always" lemmy: build: context: ../../ dockerfile: docker/dev/Dockerfile - ports: - - "127.0.0.1:8536:8536" restart: always environment: - RUST_LOG=debug @@ -24,21 +24,27 @@ services: - ../lemmy.hjson:/config/config.hjson depends_on: - postgres - - pictshare - iframely - pictshare: - image: hascheksolutions/pictshare:latest - ports: - - "127.0.0.1:8537:80" + postgres: + image: postgres:12-alpine + environment: + - POSTGRES_USER=lemmy + - POSTGRES_PASSWORD=password + - POSTGRES_DB=lemmy volumes: - - ./volumes/pictshare:/usr/share/nginx/html/data + - ./volumes/postgres:/var/lib/postgresql/data + restart: always + + pictrs: + image: asonix/pictrs:amd64-v0.1.0-r9 + user: 991:991 + volumes: + - ./volumes/pictrs:/mnt restart: always iframely: image: dogbin/iframely:latest - ports: - - "127.0.0.1:8061:80" volumes: - ../iframely.config.local.js:/iframely/config.local.js:ro restart: always diff --git a/docker/dev/nginx.conf b/docker/dev/nginx.conf new file mode 100644 index 000000000..3e4ff510e --- /dev/null +++ b/docker/dev/nginx.conf @@ -0,0 +1,40 @@ +events { + worker_connections 1024; +} + +http { + server { + listen 8536; + server_name 127.0.0.1; + #access_log off; + + # Upload limit for pictshare + client_max_body_size 50M; + + location / { + proxy_pass http://lemmy:8536; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + # WebSocket support + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + location /pictrs/ { + proxy_pass http://pictrs:8080/; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /iframely/ { + proxy_pass http://iframely:80/; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + } +} diff --git a/ui/src/components/comment-form.tsx b/ui/src/components/comment-form.tsx index 5239eb2c7..7abab7524 100644 --- a/ui/src/components/comment-form.tsx +++ b/ui/src/components/comment-form.tsx @@ -304,7 +304,7 @@ export class CommentForm extends Component { file = event; } - const imageUploadUrl = `/pictshare/api/upload.php`; + const imageUploadUrl = `/pictrs/image`; const formData = new FormData(); formData.append('file', file); @@ -317,7 +317,7 @@ export class CommentForm extends Component { }) .then(res => res.json()) .then(res => { - let url = `${window.location.origin}/pictshare/${res.url}`; + let url = `${window.location.origin}/pictrs/${res.url}`; let imageMarkdown = res.filetype == 'mp4' ? `[vid](${url}/raw)` : `![](${url})`; let content = i.state.commentForm.content; diff --git a/ui/src/components/post-form.tsx b/ui/src/components/post-form.tsx index 6f1e34e01..a9356d05d 100644 --- a/ui/src/components/post-form.tsx +++ b/ui/src/components/post-form.tsx @@ -518,9 +518,9 @@ export class PostForm extends Component { file = event; } - const imageUploadUrl = `/pictshare/api/upload.php`; + const imageUploadUrl = `/pictrs/image`; const formData = new FormData(); - formData.append('file', file); + formData.append('images', file); i.state.imageLoading = true; i.setState(i.state); @@ -531,7 +531,7 @@ export class PostForm extends Component { }) .then(res => res.json()) .then(res => { - let url = `${window.location.origin}/pictshare/${encodeURI(res.url)}`; + let url = `${window.location.origin}/pictrs/${encodeURI(res.url)}`; if (res.filetype == 'mp4') { url += '/raw'; } diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index eded9998c..c3b12fe02 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -988,7 +988,7 @@ export class User extends Component { handleImageUpload(i: User, event: any) { event.preventDefault(); let file = event.target.files[0]; - const imageUploadUrl = `/pictshare/api/upload.php`; + const imageUploadUrl = `/pictrs/image`; const formData = new FormData(); formData.append('file', file); @@ -1001,7 +1001,7 @@ export class User extends Component { }) .then(res => res.json()) .then(res => { - let url = `${window.location.origin}/pictshare/${res.url}`; + let url = `${window.location.origin}/pictrs/${res.url}`; if (res.filetype == 'mp4') { url += '/raw'; }