Skip to content

Commit 96a0b83

Browse files
committed
Examples updates
1 parent 3f435a7 commit 96a0b83

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

examples/fastapi/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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

44
COPY requirements.txt /requirements.txt
55
RUN uv pip install -r /requirements.txt
66

77
# Runtime stage: Minimal distroless image
88
FROM 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
1112
COPY --from=build-venv /.venv /.venv
1213

1314
# Copy application code
@@ -19,5 +20,5 @@ WORKDIR /app
1920
# Expose port
2021
EXPOSE 8000
2122

22-
# Run the application
23+
# Run the application using venv Python
2324
ENTRYPOINT ["/.venv/bin/python3", "-u", "main.py"]

examples/poetry-cli/Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
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
55
COPY 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
1513
COPY cli.py /app/cli.py
1614

1715
# Runtime stage: Minimal distroless image
1816
FROM 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
2120
COPY --from=build-venv /.venv /.venv
2221
COPY --from=build-venv /app /app
2322

2423
WORKDIR /app
2524

26-
# Run the CLI application
25+
# Run the CLI application using venv Python
2726
ENTRYPOINT ["/.venv/bin/python3", "-u", "cli.py"]

examples/poetry-cli/poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/poetry-cli/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = ["Your Name <you@example.com>"]
66
readme = "README.md"
77

88
[tool.poetry.dependencies]
9-
python = "^3.12"
9+
python = "^3.11"
1010
click = "^8.1.7"
1111

1212
[tool.poetry.group.dev.dependencies]

0 commit comments

Comments
 (0)