From 982a5d60f288e7738b86ad3ed35759664129e00f Mon Sep 17 00:00:00 2001 From: Skylar Saveland Date: Wed, 17 Jul 2024 15:08:34 -0700 Subject: [PATCH] Fix large uploads (#313) daphne isn't it really - but we have the websockets .. --- k8s/free2z/deployment.yaml | 35 ++++++++++++++++++++++++++++++----- k8s/free2z/nginx.conf | 21 +++++++++++---------- py/dj/free2z/prod_settings.py | 1 + py/dj/free2z/settings.py | 3 +++ 4 files changed, 45 insertions(+), 15 deletions(-) diff --git a/k8s/free2z/deployment.yaml b/k8s/free2z/deployment.yaml index 697f9307479..d3daa063cfd 100644 --- a/k8s/free2z/deployment.yaml +++ b/k8s/free2z/deployment.yaml @@ -55,8 +55,33 @@ spec: - name: GCS_HELPER_BUCKET_NAME value: "free2z-uploads" - # DJANGO APP - - name: free2z-dj + - name: free2z-gunicorn + image: us-docker.pkg.dev/free2z/gcr.io/free2z:latest + command: + - "/usr/local/bin/gunicorn" + - "dj.free2z.wsgi:application" + - "--bind" + - ":8001" + - "--access-logfile=-" # Log access logs to stdout + - "--error-logfile=-" # Log error logs to stderr + - "--timeout" + - "600" # 10 minutes upload max + resources: + limits: + cpu: 1000m + memory: 2400Mi + requests: + cpu: 200m + memory: 600Mi + envFrom: + - configMapRef: + name: free2z + - secretRef: + name: free2z + ports: + - containerPort: 8001 + + - name: free2z-daphne image: us-docker.pkg.dev/free2z/gcr.io/free2z:latest command: - "/usr/local/bin/daphne" @@ -66,10 +91,10 @@ spec: resources: limits: cpu: 1000m - memory: 2400Mi + memory: 1000Mi requests: - cpu: 100m - memory: 800Mi + cpu: 50m + memory: 600Mi envFrom: - configMapRef: name: free2z diff --git a/k8s/free2z/nginx.conf b/k8s/free2z/nginx.conf index 635cb0582ca..4ea17d4f155 100644 --- a/k8s/free2z/nginx.conf +++ b/k8s/free2z/nginx.conf @@ -45,17 +45,17 @@ server { location /adminzzz { proxy_set_header Host $http_host; - proxy_pass http://localhost:8000; + proxy_pass http://localhost:8001; } location /api { proxy_set_header Host $http_host; - proxy_pass http://localhost:8000; + proxy_pass http://localhost:8001; } location /feeds { proxy_set_header Host $http_host; - proxy_pass http://localhost:8000; + proxy_pass http://localhost:8001; } location /ws/ { @@ -78,10 +78,11 @@ server { client_max_body_size 500M; client_body_buffer_size 1M; proxy_set_header Host $http_host; - proxy_pass http://localhost:8000; + proxy_read_timeout 600s; + proxy_send_timeout 600s; + proxy_pass http://localhost:8001; } - # collectstatic location /djstatic { alias /base/dj/free2z/static/; @@ -164,7 +165,7 @@ server { location = /uploadsauth-private { internal; - proxy_pass http://localhost:8000/uploads/auth-private; + proxy_pass http://localhost:8001/uploads/auth-private; proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri; proxy_set_header Host $http_host; @@ -172,7 +173,7 @@ server { location = /uploadsauth { internal; - proxy_pass http://localhost:8000/uploads/auth; + proxy_pass http://localhost:8001/uploads/auth; proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri; proxy_set_header Host $http_host; @@ -180,7 +181,7 @@ server { location = /uploadsauth-public { internal; - proxy_pass http://localhost:8000/uploads/auth-public; + proxy_pass http://localhost:8001/uploads/auth-public; proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri; proxy_set_header Host $http_host; @@ -188,7 +189,7 @@ server { location = /uploadsauth-public-hls { internal; - proxy_pass http://localhost:8000/uploads/auth-public-hls; + proxy_pass http://localhost:8001/uploads/auth-public-hls; proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri; proxy_set_header Host $http_host; @@ -212,7 +213,7 @@ server { } if ($prerender = 1) { - proxy_pass http://localhost:8000; + proxy_pass http://localhost:8001; } # https://dev.to/chanvin/cache-control-for-react-app-with-nginx-2oef diff --git a/py/dj/free2z/prod_settings.py b/py/dj/free2z/prod_settings.py index 1879bb9335b..79d444f5d58 100644 --- a/py/dj/free2z/prod_settings.py +++ b/py/dj/free2z/prod_settings.py @@ -8,6 +8,7 @@ '.free2give.xyz', 'localhost', '127.0.0.1', + '.googleusercontent.com', ] STATIC_URL = '/djstatic/' diff --git a/py/dj/free2z/settings.py b/py/dj/free2z/settings.py index c6a2bada29a..2e11acad9e7 100644 --- a/py/dj/free2z/settings.py +++ b/py/dj/free2z/settings.py @@ -307,6 +307,9 @@ # "application/x-javascript", image/svg+xml, ] # https://cloud.google.com/storage/docs/access-control/lists#predefined-acl # GS_DEFAULT_ACL = "private" +# FILE_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 10 # 10MB +# 2621440 +# FILE_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 2.5 # 2MB NAMESPACE = os.environ.get("NAMESPACE", "test") PROJECT_ID = "free2z"