hi , i dockerize my django project and i have a problem !
users cant upload a send a medium or a big file for example 10 mb !
i want users can upload file up to 1gb .
# my setting in settings.py:
#file upload size limit
FILE_UPLOAD_MAX_MEMORY_SIZE = 0
DATA_UPLOAD_MAX_MEMORY_SIZE = 1073741824 #1G
# my Dockefile:
FROM python:3.10
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /home/Dockercontainer/Nikupen/Nikupen-Backend/app/
COPY . /home/Dockercontainer/Nikupen/Nikupen-Backend/app/
RUN apt-get update && \
apt-get upgrade -y
RUN pip install --upgrade pip && \
pip install -r requirements.txt
RUN python manage.py collectstatic --noinput
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "4", "--threads" , "4" , "--timeout", "600", "Core.wsgi:application"]
# my docker-compose :
version: '3.9'
services:
db:
image: postgres:latest
container_name: postgres_nikupen
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
env_file:
- ./.env
volumes:
- postgres_data:/var/lib/postgresql/data/
networks:
- main_nikupen
healthcheck:
test: ["CMD-SHELL", "PGPASSWORD=${DB_PASSWORD} pg_isready -h ${DB_HOST} -U ${DB_USER} -d ${DB_NAME}"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
restart: always
app:
build: .
image: nikupen_image:0.0.1
command: sh -c "python manage.py migrate && gunicorn core.wsgi -b 0.0.0.0:8000"
container_name: app_nikupen
volumes:
- /home/Dockercontainer/Nikupen/Nikupen-Backend/app
- static_volume:/home/Dockercontainer/Nikupen/Nikupen-Backend/app/static
- media_volume:/home/Dockercontainer/Nikupen/Nikupen-Backend/app/media/upload
environment:
- DB_HOST=db
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASS=${DB_PASSWORD}
networks:
- main_nikupen
depends_on:
- db
env_file:
- ./.env
restart: always
nginx:
container_name: nginx_nikupen
command: nginx -g 'daemon off;'
image: nginx:latest
depends_on:
- app
networks:
- main_nikupen
ports:
- 8065:80
restart: always
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- static_volume:/home/Dockercontainer/Nikupen/Nikupen-Backend/app/static
- media_volume:/home/Dockercontainer/Nikupen/Nikupen-Backend/app/media/upload
healthcheck:
test: ["CMD-SHELL", "curl --silent --fail localhost:80/admin/login/?next=/admin/ || exit 1"]
interval: 60s
timeout: 20s
retries: 5
start_period: 20s
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
networks:
main_nikupen:
volumes:
postgres_data:
static_volume:
media_volume:
# my nginx.conf :
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
upstream app {
server app_nikupen:8000;
}
server {
listen 80;
server_name localhost;
charset utf-8;
location /static/ {
alias /home/Dockercontainer/Nikupen/Nikupen-Backend/app/static/;
}
location /media/ {
alias /home/Dockercontainer/Nikupen/Nikupen-Backend/app/media/upload/;
}
location / {
proxy_pass http://app;
proxy_read_timeout 600s;
client_max_body_size 1000M;
proxy_request_buffering off;
}
}
}