-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (36 loc) · 1.53 KB
/
Dockerfile
File metadata and controls
37 lines (36 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# build stage
FROM docker.io/library/python:3.14-slim AS build
ARG REVISION
WORKDIR /opt/app
ENV SETUPTOOLS_SCM_PRETEND_VERSION=${REVISION} \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/opt/app \
PATH="/opt/app/.venv/bin:$PATH" \
UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy
COPY --from=ghcr.io/astral-sh/uv:0.9 /uv /uvx /bin/
COPY pyproject.toml uv.lock README.md LICENSE alembic.ini ./
COPY app ./app
COPY migrations ./migrations
RUN --mount=type=cache,target=/root/.cache/uv uv sync --frozen --no-group dev
# runtime stage
FROM docker.io/library/python:3.14-slim
ARG REVISION
LABEL org.opencontainers.image.title="FastAPI Template"
LABEL org.opencontainers.image.description="FastAPI Template"
LABEL org.opencontainers.image.source="https://github.com/devscompass/fastapi-template"
LABEL org.opencontainers.image.licenses="MIT"
LABEL org.opencontainers.image.authors="Devs Compass"
LABEL org.opencontainers.image.version="${REVISION}"
WORKDIR /opt/app
ENV SETUPTOOLS_SCM_PRETEND_VERSION=${REVISION} \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/opt/app \
PATH="/opt/app/.venv/bin:$PATH"
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
COPY --from=build /opt/app /opt/app
HEALTHCHECK --interval=10s --timeout=5s --start-period=15s --retries=5 CMD curl --fail --silent --show-error http://localhost:8080/api/ping || exit 1
EXPOSE 8080
CMD ["sh", "-c", "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8080 --no-access-log"]