From c35801a7eefc0f6a2783421afc6169d0f6779852 Mon Sep 17 00:00:00 2001 From: Sathvik Rao Poladi <36164509+Sathvik-Rao@users.noreply.github.com> Date: Wed, 27 May 2026 18:57:57 -0500 Subject: [PATCH] use repo root as Docker build context Add .dockerignore to keep build context small and exclude local/dev files. Update CI workflow and docker-compose to set the build context to the repository root and point to backend Dockerfiles. Adjust backend Dockerfile and Dockerfile.test to copy files from backend/ (requirements, app, tests, pytest.ini) and include frontend assets in the image. These changes let builds run from the repo root while avoiding sending unnecessary files to the Docker daemon. --- .dockerignore | 40 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 2 +- backend/Dockerfile | 5 +++-- backend/Dockerfile.test | 10 +++++----- docker-compose.yml | 8 ++++---- 5 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cfa5b26 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,40 @@ +# Keep the build context small now that it's the repo root. +.git +.github +.gitignore +.dockerignore + +# Local-only state and docs +data +logo +*.md +LICENSE +docker-compose.yml + +# Python cruft +**/__pycache__ +**/*.pyc +**/*.pyo +**/*.pyd +**/*.egg-info +**/.venv +**/venv +**/env +**/.pytest_cache +**/.coverage +**/htmlcov +**/.mypy_cache +**/.dmypy.json +**/.ipynb_checkpoints + +# Secrets and env +**/*.key +**/*.pem +**/secrets +.env +.env.* + +# Editor / OS +.DS_Store +.idea +.vscode diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f2a80a..87ccb24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,7 +120,7 @@ jobs: - name: Build and push backend image uses: docker/build-push-action@v6 with: - context: ./backend + context: . file: ./backend/Dockerfile push: true platforms: linux/amd64,linux/arm64/v8 diff --git a/backend/Dockerfile b/backend/Dockerfile index 212e74a..f7eb37d 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -2,10 +2,11 @@ FROM python:3.13-slim WORKDIR /backend -COPY requirements.txt . +COPY backend/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY app/ ./app/ +COPY backend/app/ ./app/ +COPY frontend/ /frontend/ EXPOSE 8000 diff --git a/backend/Dockerfile.test b/backend/Dockerfile.test index 91ba63d..efcd6de 100644 --- a/backend/Dockerfile.test +++ b/backend/Dockerfile.test @@ -1,6 +1,6 @@ # Test image — mirrors the production Dockerfile, then layers the dev deps on # top. Build it locally with: -# docker build -f Dockerfile.test -t stackresume-tests . +# docker build -f backend/Dockerfile.test -t stackresume-tests . # Or just use the compose profile: # docker compose --profile test up --build --abort-on-container-exit FROM python:3.13-slim @@ -8,12 +8,12 @@ FROM python:3.13-slim WORKDIR /backend # Production deps first so the cache hit pattern matches the prod image. -COPY requirements.txt requirements-dev.txt ./ +COPY backend/requirements.txt backend/requirements-dev.txt ./ RUN pip install --no-cache-dir -r requirements-dev.txt -COPY app/ ./app/ -COPY tests/ ./tests/ -COPY pytest.ini . +COPY backend/app/ ./app/ +COPY backend/tests/ ./tests/ +COPY backend/pytest.ini . # Make sure no provider keys leak through the host shell. ENV OPENAI_API_KEY="" \ diff --git a/docker-compose.yml b/docker-compose.yml index 276c8ed..76f16ab 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ services: backend: build: - context: ./backend - dockerfile: Dockerfile + context: . + dockerfile: backend/Dockerfile container_name: stackresume-backend ports: - "8000:8000" @@ -67,8 +67,8 @@ services: tests: profiles: ["test"] build: - context: ./backend - dockerfile: Dockerfile.test + context: . + dockerfile: backend/Dockerfile.test container_name: stackresume-tests environment: # Hard-blank any provider keys so tests never accidentally hit a real LLM.