dockerfiles

This commit is contained in:
2026-04-09 15:13:08 +02:00
parent 377e73a491
commit 4c92a97759
3 changed files with 51 additions and 0 deletions

8
.dockerignore Normal file
View File

@@ -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)

25
Dockerfile Normal file
View File

@@ -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"]

18
docker-compose.yml Normal file
View File

@@ -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