diff --git a/backend/Dockerfile b/backend/Dockerfile.dev similarity index 100% rename from backend/Dockerfile rename to backend/Dockerfile.dev diff --git a/backend/Dockerfile.prod b/backend/Dockerfile.prod new file mode 100644 index 00000000..9e0245ee --- /dev/null +++ b/backend/Dockerfile.prod @@ -0,0 +1,22 @@ +FROM python:3.11.4-alpine3.18 as requirements + +RUN pip install poetry-plugin-export + +WORKDIR /code + +COPY pyproject.toml poetry.lock ./ + +RUN poetry export --without-hashes --format=requirements.txt > requirements.txt + + +FROM python:3.11.4-alpine3.18 + +RUN apk add --no-cache gettext libintl + +WORKDIR /code + +COPY --from=requirements /code/requirements.txt . + +RUN pip install -r requirements.txt --no-cache-dir + +COPY . . diff --git a/development.yml b/development.yml index 1d0bb3e4..67ca5ea3 100644 --- a/development.yml +++ b/development.yml @@ -35,7 +35,7 @@ services: nginx: <<: *common-keys-selab container_name: nginx - image: nginx:latest + image: nginx:alpine-slim ports: - 80:80 - 443:443 @@ -52,7 +52,7 @@ services: container_name: backend build: context: $BACKEND_DIR - dockerfile: Dockerfile + dockerfile: Dockerfile.dev command: sh -c "./setup.sh; python manage.py runsslserver 0.0.0.0:8000" volumes: - ${BACKEND_DIR}:/code @@ -63,7 +63,7 @@ services: container_name: celery build: context: $BACKEND_DIR - dockerfile: Dockerfile + dockerfile: Dockerfile.dev command: sh -c "./setup.sh && celery -A ypovoli worker -l DEBUG" volumes: - ${BACKEND_DIR}:/code diff --git a/production.yml b/production.yml index 7c40cc42..e80fa8ae 100644 --- a/production.yml +++ b/production.yml @@ -34,7 +34,7 @@ x-common-keys-selab: &common-keys-selab services: nginx: <<: *common-keys-selab - image: nginx:latest + image: nginx:alpine-slim container_name: nginx_prod ports: - 80:80 @@ -62,7 +62,7 @@ services: container_name: backend_prod build: context: $BACKEND_DIR - dockerfile: Dockerfile + dockerfile: Dockerfile.prod command: sh -c "./setup.sh && gunicorn --config gunicorn_config.py ypovoli.wsgi:application" depends_on: - postgres @@ -80,10 +80,11 @@ services: container_name: celery_prod build: context: $BACKEND_DIR - dockerfile: Dockerfile + dockerfile: Dockerfile.prod command: celery -A ypovoli worker -l ERROR volumes: - - ${BACKEND_DIR}:/code + - /var/run/docker.sock:/var/run/docker.sock + - /var/lib/docker/overlay2:/var/lib/docker/overlay2 depends_on: - backend - redis diff --git a/test.yml b/test.yml index 05051584..24ec2d9b 100644 --- a/test.yml +++ b/test.yml @@ -34,7 +34,7 @@ x-common-keys-selab_test: &common-keys-selab_test services: nginx: <<: *common-keys-selab_test - image: nginx:latest + image: nginx:alpine-slim container_name: nginx volumes: - ${DATA_DIR}/nginx/nginx.test.conf:/etc/nginx/nginx.conf:ro @@ -48,7 +48,7 @@ services: container_name: backend build: context: $BACKEND_DIR - dockerfile: Dockerfile + dockerfile: Dockerfile.dev command: sh -c "./setup.sh && python manage.py runsslserver 0.0.0.0:8000" volumes: - $BACKEND_DIR:/code @@ -60,7 +60,7 @@ services: container_name: celery build: context: $BACKEND_DIR - dockerfile: Dockerfile + dockerfile: Dockerfile.dev command: sh -c "./setup.sh && celery -A ypovoli worker -l DEBUG" volumes: - $BACKEND_DIR:/code