From 68344deb040dd08d2e6f40f5bca772bf42a5e2ee Mon Sep 17 00:00:00 2001 From: Christoph Gasser Date: Wed, 23 Sep 2026 10:38:58 +0200 Subject: [PATCH] Package legacy database in application image --- .dockerignore | 8 ++++++++ README-Docker.md | 4 ++-- TelcoPortal-source/Dockerfile | 6 ++++-- docker-compose.yml | 7 +++---- 4 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3a8cd54 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.git/ +TelcoPortal-data/ +data/* +!data/telco.db +TelcoPortal-source/__pycache__/ +TelcoPortal-source/*.pyc +TelcoPortal-source/.venv/ +TelcoPortal-source/venv/ diff --git a/README-Docker.md b/README-Docker.md index 4d75a72..62561a3 100755 --- a/README-Docker.md +++ b/README-Docker.md @@ -7,8 +7,8 @@ The Docker stack contains two services: ## First start and SQLite import -1. The legacy SQLite database is included at `data/telco.db`, so Git-based deployments receive - the import source automatically. +1. The legacy SQLite database is included at `data/telco.db` and packaged into the application + image, so Git-based deployments receive the import source without a host bind mount. 2. Optionally set a database password in a `.env` file: ```env diff --git a/TelcoPortal-source/Dockerfile b/TelcoPortal-source/Dockerfile index 5f9a603..63585fe 100755 --- a/TelcoPortal-source/Dockerfile +++ b/TelcoPortal-source/Dockerfile @@ -5,10 +5,12 @@ WORKDIR /app RUN pip install --no-cache-dir --upgrade pip -COPY requirements.txt . +COPY TelcoPortal-source/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY . . +COPY TelcoPortal-source/ . +RUN mkdir -p /app/legacy-data +COPY data/telco.db /app/legacy-data/telco.db # Persistent application state (the generated Flask session key) lives in this volume. VOLUME ["/app/data"] diff --git a/docker-compose.yml b/docker-compose.yml index 4ea366e..727baf8 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,8 +17,9 @@ services: telcoportal: build: - context: ./TelcoPortal-source - dockerfile: Dockerfile + # Use the repository root so the tracked legacy database is packaged into the image. + context: . + dockerfile: TelcoPortal-source/Dockerfile container_name: telcoportal restart: unless-stopped depends_on: @@ -28,8 +29,6 @@ services: - "8092:8000" volumes: - telco-app-data:/app/data - # Read-only source for the automatic first-run SQLite import. - - ./data:/app/legacy-data:ro environment: TELCO_DATA_DIR: /app/data TELCO_DB_HOST: db