Skip to content

Commit

Permalink
Fix large uploads (ZcashFoundation#313)
Browse files Browse the repository at this point in the history
daphne isn't it really - but we have the websockets ..
  • Loading branch information
skyl authored Jul 17, 2024
1 parent 4abd139 commit 982a5d6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
35 changes: 30 additions & 5 deletions k8s/free2z/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
21 changes: 11 additions & 10 deletions k8s/free2z/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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/ {
Expand All @@ -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/;
Expand Down Expand Up @@ -164,31 +165,31 @@ 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;
}

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;
}

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;
}

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;
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions py/dj/free2z/prod_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'.free2give.xyz',
'localhost',
'127.0.0.1',
'.googleusercontent.com',
]

STATIC_URL = '/djstatic/'
Expand Down
3 changes: 3 additions & 0 deletions py/dj/free2z/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 982a5d6

Please sign in to comment.