-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
25 lines (18 loc) · 1.03 KB
/
Dockerfile
File metadata and controls
25 lines (18 loc) · 1.03 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
# We are using a two-stage build here because we use uv for dependency management
# But decide to keep it out of the production image.
# The Pre-build stage generates a pip compatible lockfile and then installs with pip
FROM ghcr.io/astral-sh/uv:alpine AS prebuild
WORKDIR /build
COPY pyproject.toml uv.lock ./
# We need to add --no-emit-project here to prevent the local source to be added to its own dependencies
RUN uv export --frozen --no-dev --no-hashes --no-emit-project -o requirements.txt
# Build stage
FROM python:3.10
WORKDIR /usr/src/
COPY --from=prebuild /build/requirements.txt /usr/src/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /usr/src/requirements.txt
COPY ./app /usr/src/app
# NB_API_PORT, representing the port on which the API will be exposed,
# is an environment variable that will always have a default value of 8000 when building the image
# but can be overridden when running the container.
ENTRYPOINT uvicorn app.main:app --proxy-headers --forwarded-allow-ips=* --host 0.0.0.0 --port ${NB_API_PORT:-8000}