-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (29 loc) · 1.24 KB
/
Dockerfile
File metadata and controls
39 lines (29 loc) · 1.24 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
38
39
FROM python:3.13-slim
# Install uv by copying the binary from the official distroless Docker image
COPY --from=ghcr.io/astral-sh/uv:0.9.24 /uv /uvx /bin/
# Install the project into `/app`
WORKDIR /app
# Enable bytecode compilation
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#compiling-bytecode
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#caching
ENV UV_LINK_MODE=copy
# Omit development dependencies
ENV UV_NO_DEV=1
# Install the project's dependencies using the lockfile and settings
# Ref: https://docs.astral.sh/uv/guides/integration/docker/#intermediate-layers
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 --locked --no-install-project
# Copy the rest of the project source code and install it
COPY . /app
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked
# Add virtual environment executables to PATH
ENV PATH="/app/.venv/bin:$PATH"
# Expose FastAPI server port
EXPOSE 8000
# Start FastAPI server
CMD ["uvicorn", "app.main:app" , "--host", "0.0.0.0", "--workers", "2"]