]> Untitled Git - lemmy.git/commitdiff
Use pictrs instead of pictshare
authorFelix Ableitner <me@nutomic.com>
Mon, 8 Jun 2020 17:52:32 +0000 (19:52 +0200)
committerFelix Ableitner <me@nutomic.com>
Mon, 8 Jun 2020 17:52:32 +0000 (19:52 +0200)
ansible/ansible.cfg
ansible/lemmy.yml
ansible/lemmy_dev.yml
ansible/templates/docker-compose.yml
ansible/templates/nginx.conf
docker/dev/docker-compose.yml
docker/dev/nginx.conf [new file with mode: 0644]
ui/src/components/comment-form.tsx
ui/src/components/post-form.tsx
ui/src/components/user.tsx

index 960a7c40fd58f72b093e88b620a40b401affae52..74b6ab2f1955975f7c50530ebc43eb802f2d3278 100644 (file)
@@ -1,5 +1,6 @@
 [defaults]
 inventory=inventory
+interpreter_python=/usr/bin/python3
 
 [ssh_connection]
 pipelining = True
index bc01623fc55cea14e7a37f3b7bbb4196cd7a170b..dcafc5eac4fa03c7b14f8c2d4aabb6a9995962e9 100644 (file)
       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'
index e9b8364f386a85357ca89d16de83f15ec650bfcd..05eb1ffed19fe5216d47c573f721974e9f479073 100644 (file)
       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
index 9ec1bfbc22d701849a6bacf04670e69ab4d31925..0b33399bde15ee713e4ded98f6b982529e60150e 100644 (file)
@@ -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
index a978c18999a755efd31663d56b59bf82b9ef1c66..b96bbce7ffaa479611d9732d3734ec3e6cd1b172 100644 (file)
@@ -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;
index 1702f66d3ff58bce14ba6371f44e364b4239d216..6c0624c4bfcc82b124c199f101a4afbd2933ffca 100644 (file)
@@ -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 (file)
index 0000000..3e4ff51
--- /dev/null
@@ -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;
+        }
+    }
+}
index 5239eb2c7a10660182154a1dd7f91b305ca367b7..7abab75242064207cb9669ed81df27f31262199a 100644 (file)
@@ -304,7 +304,7 @@ export class CommentForm extends Component<CommentFormProps, CommentFormState> {
       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<CommentFormProps, CommentFormState> {
     })
       .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;
index 6f1e34e01417e0e2b1a25dff00d6b2baf0e2df42..a9356d05d2c4ee4e079e60d9a3feabf8c11fe4ea 100644 (file)
@@ -518,9 +518,9 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
       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<PostFormProps, PostFormState> {
     })
       .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';
         }
index eded9998c53ef741d1f902670a4093f964f7d649..c3b12fe0230bd157d850305ce75da6e9e590767b 100644 (file)
@@ -988,7 +988,7 @@ export class User extends Component<any, UserState> {
   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<any, UserState> {
     })
       .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';
         }