From 705371eaf332591f6391a7f741a9889c5e95c0cd Mon Sep 17 00:00:00 2001 From: pablohashescobar <118773738+pablohashescobar@users.noreply.github.com> Date: Tue, 6 Jun 2023 19:15:42 +0530 Subject: [PATCH] fix: file upload size limit (#1218) --- docker-compose-hub.yml | 21 ++++++------ docker-compose.yml | 39 +++++++++++------------ nginx/Dockerfile | 10 ++++-- nginx/env.sh | 4 +++ nginx/{nginx.conf => nginx.conf.template} | 5 ++- 5 files changed, 46 insertions(+), 33 deletions(-) create mode 100644 nginx/env.sh rename nginx/{nginx.conf => nginx.conf.template} (81%) diff --git a/docker-compose-hub.yml b/docker-compose-hub.yml index 14331532c..f259f6391 100644 --- a/docker-compose-hub.yml +++ b/docker-compose-hub.yml @@ -109,8 +109,8 @@ services: volumes: - uploads:/export environment: - MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID} - MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY} + MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID} + MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY} command: server /export --console-address ":9090" createbuckets: @@ -127,13 +127,16 @@ services: # Comment this if you already have a reverse proxy running plane-proxy: - container_name: planeproxy - image: makeplane/plane-proxy:latest - ports: - - ${NGINX_PORT}:80 - depends_on: - - plane-web - - plane-api + container_name: planeproxy + image: makeplane/plane-proxy:latest + ports: + - ${NGINX_PORT}:80 + environment: + FILE_SIZE_LIMIT: ${FILE_SIZE_LIMIT:-5242880} + BUCKET_NAME: ${AWS_S3_BUCKET_NAME:-uploads} + depends_on: + - plane-web + - plane-api volumes: diff --git a/docker-compose.yml b/docker-compose.yml index 5079d5379..45a74afb6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,10 +4,10 @@ services: plane-web: container_name: planefrontend build: - context: . - dockerfile: ./apps/app/Dockerfile.web - args: - NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 + context: . + dockerfile: ./apps/app/Dockerfile.web + args: + NEXT_PUBLIC_API_BASE_URL: http://localhost:8000 restart: always command: [ "/usr/local/bin/start.sh" ] environment: @@ -24,8 +24,8 @@ services: plane-api: container_name: planebackend build: - context: ./apiserver - dockerfile: Dockerfile.api + context: ./apiserver + dockerfile: Dockerfile.api restart: always command: ./bin/takeoff environment: @@ -61,8 +61,8 @@ services: plane-worker: container_name: planebgworker build: - context: ./apiserver - dockerfile: Dockerfile.api + context: ./apiserver + dockerfile: Dockerfile.api restart: always command: ./bin/worker environment: @@ -88,8 +88,8 @@ services: OPENAI_API_KEY: ${OPENAI_API_KEY} GPT_ENGINE: ${GPT_ENGINE} SECRET_KEY: ${SECRET_KEY} - DEFAULT_EMAIL: ${DEFAULT_EMAIL} - DEFAULT_PASSWORD: ${DEFAULT_PASSWORD} + DEFAULT_EMAIL: ${DEFAULT_EMAIL:-captain@plane.so} + DEFAULT_PASSWORD: ${DEFAULT_PASSWORD:-password123} USE_MINIO: ${USE_MINIO} depends_on: - plane-api @@ -130,27 +130,24 @@ services: createbuckets: image: minio/mc entrypoint: > - /bin/sh -c " - /usr/bin/mc config host add plane-minio http://plane-minio:9000 \$AWS_ACCESS_KEY_ID \$AWS_SECRET_ACCESS_KEY; - /usr/bin/mc mb plane-minio/\$AWS_S3_BUCKET_NAME; - /usr/bin/mc anonymous set download plane-minio/\$AWS_S3_BUCKET_NAME; - exit 0; - " + /bin/sh -c " /usr/bin/mc config host add plane-minio http://plane-minio:9000 \$AWS_ACCESS_KEY_ID \$AWS_SECRET_ACCESS_KEY; /usr/bin/mc mb plane-minio/\$AWS_S3_BUCKET_NAME; /usr/bin/mc anonymous set download plane-minio/\$AWS_S3_BUCKET_NAME; exit 0; " depends_on: - plane-minio plane-proxy: container_name: planeproxy build: - context: ./nginx - dockerfile: Dockerfile + context: ./nginx + dockerfile: Dockerfile restart: always ports: - ${NGINX_PORT}:80 + environment: + FILE_SIZE_LIMIT: ${FILE_SIZE_LIMIT:-5242880} + BUCKET_NAME: ${AWS_S3_BUCKET_NAME:-uploads} depends_on: - - plane-web - - plane-api - + - plane-web + - plane-api volumes: pgdata: diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 4948a0109..b1aef1a20 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,4 +1,10 @@ -FROM nginx:1.21-alpine +FROM nginx:1.25.0-alpine RUN rm /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/nginx.conf \ No newline at end of file +COPY nginx.conf.template /etc/nginx/nginx.conf.template + +COPY ./env.sh /docker-entrypoint.sh + +RUN chmod +x /docker-entrypoint.sh +# Update all environment variables +CMD ["/docker-entrypoint.sh"] diff --git a/nginx/env.sh b/nginx/env.sh new file mode 100644 index 000000000..59e4a46a0 --- /dev/null +++ b/nginx/env.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +envsubst < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf +exec nginx -g 'daemon off;' diff --git a/nginx/nginx.conf b/nginx/nginx.conf.template similarity index 81% rename from nginx/nginx.conf rename to nginx/nginx.conf.template index b57dc97f2..206c94b51 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf.template @@ -8,6 +8,9 @@ server { listen 80; root /www/data/; access_log /var/log/nginx/access.log; + + client_max_body_size ${FILE_SIZE_LIMIT}; + location / { proxy_pass http://planefrontend:3000/; } @@ -16,7 +19,7 @@ server { proxy_pass http://planebackend:8000/api/; } - location /uploads/ { + location /${BUCKET_NAME}/ { proxy_pass http://plane-minio:9000/uploads/; } }