separate data from code

This commit is contained in:
Marc Koch 2025-04-25 17:06:49 +02:00
parent 244c9f376e
commit 1a2e88948a
Signed by: marc
GPG Key ID: 12406554CFB028B9
4 changed files with 8 additions and 3 deletions

View File

@ -6,6 +6,8 @@ ENV PYTHONUNBUFFERED 1
WORKDIR /app WORKDIR /app
RUN mkdir /data
COPY src/ ./ COPY src/ ./
COPY requirements.txt . COPY requirements.txt .
COPY README.md index.md COPY README.md index.md
@ -14,7 +16,8 @@ COPY version.txt .
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
RUN groupadd -r app-user && useradd -r -g app-user app-user && \ RUN groupadd -r app-user && useradd -r -g app-user app-user && \
chown -R app-user:app-user /app chown -R app-user:app-user /app && \
chown -R app-user:app-user /data
USER app-user USER app-user

View File

@ -8,7 +8,7 @@ services:
ports: ports:
- "8000:8000" - "8000:8000"
volumes: volumes:
- app-data:/app - app-data:/data
env_file: .env env_file: .env
volumes: volumes:

View File

@ -20,6 +20,7 @@ DJANGO_SECRET_KEY = os.getenv("DJANGO_SECRET_KEY") \
else secrets.token_hex(40) if os.getenv("DEBUG") else None else secrets.token_hex(40) if os.getenv("DEBUG") else None
DEBUG = os.getenv("DEBUG") DEBUG = os.getenv("DEBUG")
BASE_DIR = Path(__file__).resolve().parent BASE_DIR = Path(__file__).resolve().parent
DATA_DIR = BASE_DIR.parent / "data"
# Check if all required values are set # Check if all required values are set
if not DJANGO_SECRET_KEY and not DEBUG: if not DJANGO_SECRET_KEY and not DEBUG:
@ -32,6 +33,7 @@ app = Django(
TIME_ZONE=os.getenv("TIME_ZONE", "Europe/Berlin"), TIME_ZONE=os.getenv("TIME_ZONE", "Europe/Berlin"),
ALLOWED_HOSTS=["localhost"] + [host for host in ALLOWED_HOSTS=["localhost"] + [host for host in
os.getenv("ALLOWED_HOSTS", "").split(",")], os.getenv("ALLOWED_HOSTS", "").split(",")],
SQLITE_DATABASE=DATA_DIR / "db.sqlite3",
DEBUG=DEBUG, DEBUG=DEBUG,
TEMPLATES_DIR=BASE_DIR / "templates", TEMPLATES_DIR=BASE_DIR / "templates",
STATICFILES_DIRS=[ STATICFILES_DIRS=[

View File

@ -1 +1 @@
1.0.1 1.0.2