From 1a2e88948a939c7a61f24afddcf89731e90bc41d Mon Sep 17 00:00:00 2001 From: Marc Koch Date: Fri, 25 Apr 2025 17:06:49 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20separate=20data=20from=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 5 ++++- docker-compose.yaml | 2 +- src/booking.py | 2 ++ version.txt | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index ddec37e..6348263 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ ENV PYTHONUNBUFFERED 1 WORKDIR /app +RUN mkdir /data + COPY src/ ./ COPY requirements.txt . COPY README.md index.md @@ -14,7 +16,8 @@ COPY version.txt . RUN pip install --no-cache-dir -r requirements.txt 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 diff --git a/docker-compose.yaml b/docker-compose.yaml index e6d1a88..9af0575 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,7 +8,7 @@ services: ports: - "8000:8000" volumes: - - app-data:/app + - app-data:/data env_file: .env volumes: diff --git a/src/booking.py b/src/booking.py index 0c9ff76..f1fe95f 100644 --- a/src/booking.py +++ b/src/booking.py @@ -20,6 +20,7 @@ DJANGO_SECRET_KEY = os.getenv("DJANGO_SECRET_KEY") \ else secrets.token_hex(40) if os.getenv("DEBUG") else None DEBUG = os.getenv("DEBUG") BASE_DIR = Path(__file__).resolve().parent +DATA_DIR = BASE_DIR.parent / "data" # Check if all required values are set if not DJANGO_SECRET_KEY and not DEBUG: @@ -32,6 +33,7 @@ app = Django( TIME_ZONE=os.getenv("TIME_ZONE", "Europe/Berlin"), ALLOWED_HOSTS=["localhost"] + [host for host in os.getenv("ALLOWED_HOSTS", "").split(",")], + SQLITE_DATABASE=DATA_DIR / "db.sqlite3", DEBUG=DEBUG, TEMPLATES_DIR=BASE_DIR / "templates", STATICFILES_DIRS=[ diff --git a/version.txt b/version.txt index 7f20734..e6d5cb8 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.1 \ No newline at end of file +1.0.2 \ No newline at end of file