File tree Expand file tree Collapse file tree 4 files changed +15
-15
lines changed
Expand file tree Collapse file tree 4 files changed +15
-15
lines changed Original file line number Diff line number Diff line change 11# Build stage: Install dependencies in virtual environment
2- FROM ghcr.io/jski/python-container-builder:3.12 as build-venv
2+ FROM ghcr.io/jski/python-container-builder:3.11 AS build-venv
33
44COPY requirements.txt /requirements.txt
55RUN uv pip install -r /requirements.txt
66
77# Runtime stage: Minimal distroless image
88FROM gcr.io/distroless/python3-debian12
99
10- # Copy virtual environment from build stage
10+ # Copy Python installation and virtual environment from build stage
11+ COPY --from=build-venv /usr/local /usr/local
1112COPY --from=build-venv /.venv /.venv
1213
1314# Copy application code
@@ -19,5 +20,5 @@ WORKDIR /app
1920# Expose port
2021EXPOSE 8000
2122
22- # Run the application
23+ # Run the application using venv Python
2324ENTRYPOINT ["/.venv/bin/python3" , "-u" , "main.py" ]
Original file line number Diff line number Diff line change 11# Build stage: Use Poetry to export dependencies
2- FROM ghcr.io/jski/python-container-builder:3.12 as build-venv
2+ FROM ghcr.io/jski/python-container-builder:3.11 AS build-venv
33
44# Copy Poetry files
55COPY pyproject.toml poetry.lock* /
66
7- # Export Poetry dependencies to requirements.txt format
8- # This is faster and more compatible with uv than installing Poetry in the container
9- RUN poetry export --without-hashes --format=requirements.txt > requirements.txt
10-
11- # Install dependencies using uv (much faster than pip)
12- RUN uv pip install -r requirements.txt
7+ # Install dependencies using Poetry directly
8+ # Configure Poetry to not create its own venv (use the existing one)
9+ RUN poetry config virtualenvs.create false && \
10+ poetry install --only main --no-root
1311
1412# Copy application code
1513COPY cli.py /app/cli.py
1614
1715# Runtime stage: Minimal distroless image
1816FROM gcr.io/distroless/python3-debian12
1917
20- # Copy virtual environment and application
18+ # Copy Python installation and virtual environment from build stage
19+ COPY --from=build-venv /usr/local /usr/local
2120COPY --from=build-venv /.venv /.venv
2221COPY --from=build-venv /app /app
2322
2423WORKDIR /app
2524
26- # Run the CLI application
25+ # Run the CLI application using venv Python
2726ENTRYPOINT ["/.venv/bin/python3" , "-u" , "cli.py" ]
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ authors = ["Your Name <you@example.com>"]
66readme = " README.md"
77
88[tool .poetry .dependencies ]
9- python = " ^3.12 "
9+ python = " ^3.11 "
1010click = " ^8.1.7"
1111
1212[tool .poetry .group .dev .dependencies ]
You can’t perform that action at this time.
0 commit comments