From 4c92a977591868daf725889b6da77be3b93fdc31 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Thu, 9 Apr 2026 15:13:08 +0200 Subject: [PATCH] dockerfiles --- .dockerignore | 8 ++++++++ Dockerfile | 25 +++++++++++++++++++++++++ docker-compose.yml | 18 ++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..aafddcd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +# The source code is bind-mounted at runtime, not copied into the image. +# .dockerignore only matters for what's sent to the Docker build daemon +# (i.e. the COPY requirements.txt step in the Dockerfile). +.git/ +__pycache__/ +*.pyc + +# Keep requirements.txt (needed for the COPY in Dockerfile) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c9b8656 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM python:3.12-slim + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +WORKDIR /app + +# Install build dependencies (needed for some Python packages, e.g. Pillow) +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + && rm -rf /var/lib/apt/lists/* + +# Pre-install requirements at build time so the layer is cached. +# The entrypoint re-runs pip install on every container start to pick up +# any changes that arrived via git pull without needing a rebuild. +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# The source code is NOT copied here — the git repo is bind-mounted +# at /app at runtime (see docker-compose.yml). + +EXPOSE 8000 + +# entrypoint.sh lives in the mounted repo at /app/docker/entrypoint.sh +ENTRYPOINT ["/app/docker/entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7c8d3b4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +# Usage: +# cd /docker/websites/blechreiz +# docker compose up -d --build # first start / after Dockerfile changes +# git pull && docker compose restart # deploy new code (entrypoint handles the rest) + +services: + blechreiz: + build: + context: . + dockerfile: Dockerfile + volumes: + - .:/app # git repo is the live source + env_file: + - blechreiz/.env + ports: + - "127.0.0.1:8000:8000" # only localhost; HTTPS handled by external proxy + restart: unless-stopped +