-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support setting Python version when generating Dockerfile (#152)
- Loading branch information
1 parent
f361836
commit de6e985
Showing
18 changed files
with
309 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS build | ||
FROM ghcr.io/astral-sh/uv:python{{ .PythonVersion }}-bookworm-slim AS build | ||
LABEL maintainer="[email protected]" | ||
|
||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy | ||
|
@@ -16,7 +16,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \ | |
uv sync --frozen --no-dev | ||
|
||
|
||
FROM python:3.12-slim-bookworm | ||
FROM python:{{ .PythonVersion }}-slim-bookworm | ||
LABEL maintainer="[email protected]" | ||
|
||
RUN addgroup application-group --gid 1001 && \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS build | ||
LABEL maintainer="[email protected]" | ||
|
||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy | ||
|
||
WORKDIR /app | ||
|
||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=uv.lock,target=uv.lock \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
uv sync --frozen --no-install-project --no-dev | ||
|
||
ADD . /app | ||
|
||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv sync --frozen --no-dev | ||
|
||
|
||
FROM python:3.13-slim-bookworm | ||
LABEL maintainer="[email protected]" | ||
|
||
RUN addgroup application-group --gid 1001 && \ | ||
adduser application-user --uid 1001 \ | ||
--ingroup application-group \ | ||
--disabled-password | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app . | ||
|
||
ENV PATH="/app/.venv/bin:$PATH" | ||
|
||
RUN chown --recursive application-user . | ||
USER application-user | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["fastapi", "run", "--host", "0.0.0.0", "--port", "8080", "/app/app/main.py"] | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM ghcr.io/astral-sh/uv:python3.10-bookworm-slim AS build | ||
LABEL maintainer="[email protected]" | ||
|
||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy | ||
|
||
WORKDIR /app | ||
|
||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
--mount=type=bind,source=uv.lock,target=uv.lock \ | ||
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \ | ||
uv sync --frozen --no-install-project --no-dev | ||
|
||
ADD . /app | ||
|
||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv sync --frozen --no-dev | ||
|
||
|
||
FROM python:3.10-slim-bookworm | ||
LABEL maintainer="[email protected]" | ||
|
||
RUN addgroup application-group --gid 1001 && \ | ||
adduser application-user --uid 1001 \ | ||
--ingroup application-group \ | ||
--disabled-password | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=build /app . | ||
|
||
ENV PATH="/app/.venv/bin:$PATH" | ||
|
||
RUN chown --recursive application-user . | ||
USER application-user | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["fastapi", "run", "--host", "0.0.0.0", "--port", "8080", "/app/app/main.py"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.