From c1a5d7a42596d3d74ec0a90f8d19083d4557613e Mon Sep 17 00:00:00 2001 From: Tianyu Liu Date: Fri, 12 Jun 2026 20:48:34 +0200 Subject: [PATCH] fix(docker): stop COPYing removed alembic_location/alembic_poo into the image M1-T04 deleted the alembic_location / alembic_poo chains and their .ini files, but the Dockerfile still COPYed those four paths, so the release image build failed at 'COPY alembic_poo.ini ./' (path not found). Drop the four stale COPY lines (only alembic_app remains). Add test_dockerfile_copy_sources_exist, which asserts every Dockerfile COPY source exists in the build context, so this class of breakage fails pytest instead of only surfacing in the image CI. Verified with a real local 'docker build' (succeeds) and pytest (98 passed). --- Dockerfile | 4 ---- tests/test_deployment.py | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 26479da..d06d5b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,10 +11,6 @@ RUN pip install --no-cache-dir -r requirements.txt COPY app ./app COPY alembic_app ./alembic_app COPY alembic_app.ini ./ -COPY alembic_location ./alembic_location -COPY alembic_location.ini ./ -COPY alembic_poo ./alembic_poo -COPY alembic_poo.ini ./ COPY scripts ./scripts COPY docker ./docker COPY README.md ./ diff --git a/tests/test_deployment.py b/tests/test_deployment.py index 6bc10b2..5d84fb1 100644 --- a/tests/test_deployment.py +++ b/tests/test_deployment.py @@ -64,6 +64,24 @@ def test_image_defaults_to_uvicorn_only() -> None: assert "poo_db_adopt" not in entrypoint +def test_dockerfile_copy_sources_exist() -> None: + """Every path the Dockerfile COPYs from the build context must exist in the + repo, so the image build cannot break on a stale COPY of a removed path + (e.g. the retired alembic_location / alembic_poo chains).""" + dockerfile = (PROJECT_ROOT / "Dockerfile").read_text() + for raw_line in dockerfile.splitlines(): + line = raw_line.strip() + if not line.startswith("COPY "): + continue + # Drop the "COPY" keyword and any flags (e.g. --from=, --chown=). + tokens = [t for t in line.split()[1:] if not t.startswith("--")] + # COPY : the last token is the destination. + for src in tokens[:-1]: + assert (PROJECT_ROOT / src).exists(), ( + f"Dockerfile COPY source does not exist in the build context: {src}" + ) + + def test_migration_runner_initializes_and_is_idempotent( tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: