From 50995366c1728536907fbeded492f681c56c1b0d Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 14 May 2026 11:38:24 +0200 Subject: [PATCH] Fuller docker config --- Dockerfile | 24 ++++++++++++++++++++++++ Makefile | 2 +- docker-compose.yml | 6 +++++- scripts/entrypoint.sh | 13 +++++++++++++ src/wolnelektury/settings/basic.py | 2 +- 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100755 scripts/entrypoint.sh diff --git a/Dockerfile b/Dockerfile index ed113fe3b..b23530b9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,13 +37,37 @@ WORKDIR /app/src RUN mkdir /app/.ipython + + + FROM base AS dev #RUN pip install --no-cache-dir coverage + + FROM base AS prod +USER root + RUN pip install --no-cache-dir gunicorn +USER app + COPY src /app/src + + + + +FROM prod AS static-builder + +RUN python manage.py collectstatic --noinput + + + +FROM nginx:alpine AS nginx + +# COPY nginx.conf conf.d/... + +COPY --from=static-builder /app/var/static /app/var/static diff --git a/Makefile b/Makefile index 98a68987c..59e222af6 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ build: UID=$(UID) GID=$(GID) docker compose build shell: - UID=$(UID) GID=$(GID) docker compose run --rm web bash + UID=$(UID) GID=$(GID) docker compose exec web bash logs: docker compose logs -f diff --git a/docker-compose.yml b/docker-compose.yml index b6515098d..bda15bb40 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,16 +7,21 @@ x-app-base: &app-base GID: ${GID:-1000} env_file: - .env + environment: + DEBUG: "True" volumes: - ./src:/app/src + - ./scripts:/app/scripts - ./var/media:/app/var/media - ./var/static:/app/var/static - ./var/counters/:/app/var/counters + - ${LIBRARIAN:-/nonexistent}:/${LIBRARIAN:+edita}ble/librarian - ipython:/app/.ipython depends_on: - db - redis - memcached + entrypoint: /app/scripts/entrypoint.sh services: web: @@ -31,7 +36,6 @@ services: db: image: postgres:18 - container_name: db env_file: - .env volumes: diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100755 index 000000000..7d809ef83 --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# For use in development only. +# Installs in editable mode any libs mounted under /editable/ +# This way, we can easily work on e.g. librarian. + +for lib in /editable/* +do + [ -d "$lib" ] || continue + pip install -e $lib +done + +exec "$@" diff --git a/src/wolnelektury/settings/basic.py b/src/wolnelektury/settings/basic.py index 5c86787f8..84503ed5f 100644 --- a/src/wolnelektury/settings/basic.py +++ b/src/wolnelektury/settings/basic.py @@ -3,7 +3,7 @@ # import os -DEBUG = True +DEBUG = os.environ.get('DEBUG', '') ADMINS = [ # ('Your Name', 'your_email@domain.com'), -- 2.20.1