From b12f151b8d5651636861a72a56b9cff866ac88db Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Thu, 8 May 2025 20:56:55 +0200 Subject: [PATCH] Add Docker support with Dockerfile and docker-compose; implement entrypoint script for application startup --- Dockerfile | 5 ++--- compose.yaml | 23 +++++++++++++++++++++++ entrypoint.sh | 5 +++++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 compose.yaml create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index f75aad7..7e7eeaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,9 +10,8 @@ USER nummi ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 +ENV NUMMI_CONFIG=/nummi/config.toml RUN uv sync --locked -WORKDIR /app/nummi - -CMD ["uv", "run", "gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "nummi.wsgi:application"] +CMD ["./entrypoint.sh"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..de60602 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,23 @@ +services: + nummi: + image: code.edgarpierre.fr/edpibu/nummi:main + container_name: nummi + restart: unless-stopped + ports: + - 33001:8000 + volumes: + - /docker/nummi/config:/nummi + - /docker/nummi/static:/app/static + - /docker/nummi/media:/app/media + depends_on: + - postgres + + postgres: + image: postgres:17-alpine + container_name: nummi_postgres + restart: unless-stopped + environment: + POSTGRES_USER: nummi + POSTGRES_PASSWORD: + volumes: + - /docker/nummi/postgres:/var/lib/postgresql/data \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..0312989 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +cd nummi +uv run manage.py collectstatic --noinput +uv run manage.py migrate --noinput +uv run gunicorn --bind :8000 --workers 2 nummi.wsgi:application \ No newline at end of file