Fuller docker config
authorRadek Czajka <rczajka@rczajka.pl>
Thu, 14 May 2026 09:38:24 +0000 (11:38 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Thu, 14 May 2026 09:38:24 +0000 (11:38 +0200)
Dockerfile
Makefile
docker-compose.yml
scripts/entrypoint.sh [new file with mode: 0755]
src/wolnelektury/settings/basic.py

index ed113fe..b23530b 100644 (file)
@@ -37,13 +37,37 @@ WORKDIR /app/src
 
 RUN mkdir /app/.ipython
 
 
 RUN mkdir /app/.ipython
 
+
+
+
 FROM base AS dev
 
 #RUN pip install --no-cache-dir coverage
 
 
 FROM base AS dev
 
 #RUN pip install --no-cache-dir coverage
 
 
+
+
 FROM base AS prod
 
 FROM base AS prod
 
+USER root
+
 RUN pip install --no-cache-dir gunicorn
 
 RUN pip install --no-cache-dir gunicorn
 
+USER app
+
 COPY src /app/src
 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
index 98a6898..59e222a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ build:
        UID=$(UID) GID=$(GID) docker compose build
 
 shell:
        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
 
 logs:
        docker compose logs -f
index b651509..bda15bb 100644 (file)
@@ -7,16 +7,21 @@ x-app-base: &app-base
       GID: ${GID:-1000}
   env_file:
    - .env
       GID: ${GID:-1000}
   env_file:
    - .env
+  environment:
+    DEBUG: "True"
   volumes:
    - ./src:/app/src
   volumes:
    - ./src:/app/src
+   - ./scripts:/app/scripts
    - ./var/media:/app/var/media
    - ./var/static:/app/var/static
    - ./var/counters/:/app/var/counters
    - ./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
    - ipython:/app/.ipython
   depends_on:
    - db
    - redis
    - memcached
+  entrypoint: /app/scripts/entrypoint.sh
 
 services:
   web:
 
 services:
   web:
@@ -31,7 +36,6 @@ services:
 
   db:
     image: postgres:18
 
   db:
     image: postgres:18
-    container_name: db
     env_file:
       - .env
     volumes:
     env_file:
       - .env
     volumes:
diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh
new file mode 100755 (executable)
index 0000000..7d809ef
--- /dev/null
@@ -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 "$@"
index 5c86787..84503ed 100644 (file)
@@ -3,7 +3,7 @@
 #
 import os
 
 #
 import os
 
-DEBUG = True
+DEBUG = os.environ.get('DEBUG', '')
 
 ADMINS = [
     # ('Your Name', 'your_email@domain.com'),
 
 ADMINS = [
     # ('Your Name', 'your_email@domain.com'),