Skip to content

Commit aa3deee

Browse files
manavgupclaude
andcommitted
fix(docker): Update Dockerfiles and workflows for Poetry root migration
Fixes #502 - Update all Docker and CI/CD references after moving Poetry config from backend/ to project root (Issue #501). Changes: 1. **Dockerfiles** (backend/Dockerfile.backend, Dockerfile.codeengine): - Add POETRY_ROOT_MIGRATION cache-bust ARG to both stages - Update COPY commands to reference pyproject.toml and poetry.lock from project root - Move poetry.lock copy alongside pyproject.toml for consistency - Add explanatory comments about Issue #501 migration 2. **GitHub Actions Workflows**: - Update 05-ci.yml: Fix poetry cache key to use 'poetry.lock' instead of 'backend/poetry.lock' - Update 03-build-secure.yml: Change backend context from 'backend' to '.' for correct file resolution 3. **PyTorch Version Update**: - Upgrade torch from 2.5.0+cpu to 2.6.0+cpu - Upgrade torchvision from 0.20.0+cpu to 0.21.0+cpu - Reason: 2.5.0+cpu not available for ARM64 architecture - New versions are compatible with both ARM64 and x86_64 4. **Secret Management**: - Add pragma: allowlist secret comments to test secrets in 05-ci.yml - Prevents false positives in detect-secrets pre-commit hook Impact: - Fixes failing CI/CD test: TestMakefileTargetsDirect.test_make_build_backend_minimal - Docker builds now correctly find pyproject.toml and poetry.lock at project root - Maintains compatibility with both local development (ARM64) and CI (x86_64) - GitHub Actions workflows correctly cache Poetry dependencies Testing: - Docker build context validated - All references to backend/pyproject.toml and backend/poetry.lock removed - Cache keys updated to match new file locations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f74079a commit aa3deee

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

.github/workflows/03-build-secure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
include:
3535
- service: backend
3636
dockerfile: backend/Dockerfile.backend
37-
context: backend
37+
context: .
3838
image_name: rag-modulo-backend
3939
ghcr_image: ghcr.io/manavgup/rag_modulo/backend
4040
- service: frontend

.github/workflows/05-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ jobs:
7272
env:
7373
# Essential environment variables for current atomic tests
7474
# TODO: Remove these once issue #172 (test isolation) is fixed
75-
JWT_SECRET_KEY: test-secret-key-for-ci
75+
JWT_SECRET_KEY: test-secret-key-for-ci # pragma: allowlist secret
7676
RAG_LLM: openai
7777
WATSONX_INSTANCE_ID: test-instance-id
78-
WATSONX_APIKEY: test-api-key
78+
WATSONX_APIKEY: test-api-key # pragma: allowlist secret
7979
WATSONX_URL: https://test.watsonx.com
8080
# Additional variables needed by tests
8181
VECTOR_DB: milvus
@@ -97,7 +97,7 @@ jobs:
9797
path: |
9898
~/.cache/pypoetry
9999
backend/.venv
100-
key: ${{ runner.os }}-poetry-${{ hashFiles('backend/poetry.lock') }}
100+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
101101
restore-keys: |
102102
${{ runner.os }}-poetry-
103103

Dockerfile.codeengine

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,20 @@ ENV PATH="/root/.cargo/bin:${PATH}"
2929

3030
WORKDIR /app
3131

32+
# CACHE_BUST: Poetry files moved to project root (Issue #501)
33+
# This ARG invalidates Docker cache when pyproject.toml location changes
34+
ARG POETRY_ROOT_MIGRATION=20251027
35+
3236
# Copy dependency files first for better layer caching
33-
COPY backend/pyproject.toml backend/poetry.lock ./
37+
# Poetry config moved from backend/ to project root
38+
COPY pyproject.toml poetry.lock ./
3439

3540
# Install CPU-only PyTorch first to avoid CUDA dependencies (~6GB savings)
36-
# Using compatible versions for ARM64
41+
# Using torch 2.6.0 CPU-only version (compatible with ARM64 and x86_64)
3742
RUN --mount=type=cache,target=/root/.cache/pip \
3843
pip install --no-cache-dir \
39-
torch==2.5.0+cpu \
40-
torchvision==0.20.0+cpu \
44+
torch==2.6.0+cpu \
45+
torchvision==0.21.0+cpu \
4146
--index-url https://download.pytorch.org/whl/cpu
4247

4348
# Configure pip globally to prevent any CUDA torch reinstalls
@@ -64,20 +69,26 @@ RUN find /usr/local -name "*.pyc" -delete && \
6469
# Final stage - clean runtime
6570
FROM python:3.12-slim
6671

72+
# CACHE_BUST: Poetry files moved to project root (Issue #501)
73+
# Ensure final stage cache is also invalidated
74+
ARG POETRY_ROOT_MIGRATION=20251027
75+
6776
WORKDIR /app
6877

6978
# Copy system Python packages from builder
7079
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
7180
COPY --from=builder /usr/local/bin /usr/local/bin
7281

73-
# Copy only essential application files
82+
# Copy Poetry config from project root (moved from backend/ in Issue #501)
83+
COPY pyproject.toml poetry.lock ./
84+
85+
# Copy only essential application files from backend directory
7486
COPY backend/main.py backend/healthcheck.py ./
7587
COPY backend/rag_solution/ ./rag_solution/
7688
COPY backend/auth/ ./auth/
7789
COPY backend/core/ ./core/
7890
COPY backend/cli/ ./cli/
7991
COPY backend/vectordbs/ ./vectordbs/
80-
COPY backend/pyproject.toml ./
8192

8293
# Create a non-root user and group
8394
RUN groupadd --gid 10001 backend && \

backend/Dockerfile.backend

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ ARG POETRY_ROOT_MIGRATION=20251027
3737
COPY pyproject.toml poetry.lock ./
3838

3939
# Install CPU-only PyTorch first to avoid CUDA dependencies (~6GB savings)
40-
# Using torch 2.5.0 to match torchvision 0.20.0 compatibility
40+
# Using torch 2.6.0 CPU-only version (compatible with ARM64 and x86_64)
4141
RUN --mount=type=cache,target=/root/.cache/pip \
4242
pip install --no-cache-dir \
43-
torch==2.5.0+cpu \
44-
torchvision==0.20.0+cpu \
43+
torch==2.6.0+cpu \
44+
torchvision==0.21.0+cpu \
4545
--index-url https://download.pytorch.org/whl/cpu
4646

4747
# Configure pip globally to prevent any CUDA torch reinstalls
@@ -68,20 +68,26 @@ RUN find /usr/local -name "*.pyc" -delete && \
6868
# Final stage - clean runtime
6969
FROM python:3.12-slim
7070

71+
# CACHE_BUST: Poetry files moved to project root (Issue #501)
72+
# Ensure final stage cache is also invalidated
73+
ARG POETRY_ROOT_MIGRATION=20251027
74+
7175
WORKDIR /app
7276

7377
# Copy system Python packages from builder
7478
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
7579
COPY --from=builder /usr/local/bin /usr/local/bin
7680

81+
# Copy Poetry config from project root (moved from backend/ in Issue #501)
82+
COPY pyproject.toml poetry.lock ./
83+
7784
# Copy only essential application files from backend directory
7885
COPY backend/main.py backend/healthcheck.py ./
7986
COPY backend/rag_solution/ ./rag_solution/
8087
COPY backend/auth/ ./auth/
8188
COPY backend/core/ ./core/
8289
COPY backend/cli/ ./cli/
8390
COPY backend/vectordbs/ ./vectordbs/
84-
COPY pyproject.toml ./
8591

8692
# Create a non-root user and group
8793
RUN groupadd --gid 10001 backend && \

0 commit comments

Comments
 (0)