-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
33 lines (25 loc) · 1.13 KB
/
Copy pathDockerfile
File metadata and controls
33 lines (25 loc) · 1.13 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
FROM python:3.13-slim
# uv from official image (fast, deterministic Python package manager).
COPY --from=ghcr.io/astral-sh/uv:0.5 /uv /uvx /usr/local/bin/
ENV UV_LINK_MODE=copy \
UV_COMPILE_BYTECODE=1 \
UV_PYTHON_DOWNLOADS=never
WORKDIR /app
# Install dependencies first (cacheable layer; project source not needed yet)
COPY pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev
# Copy project source and install the package itself
COPY benthos_api/ ./benthos_api/
COPY README.md ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev
# Drop privileges
RUN useradd --create-home --uid 1000 benthos && chown -R benthos:benthos /app
USER benthos
# Render injects $PORT at runtime. The sh -c form is required for shell
# expansion of ${PORT:-8000} — exec form (JSON array) would treat the
# ${...} as a literal arg. Local docker-compose runs without $PORT set,
# so the default 8000 applies and existing dev flow is unchanged.
EXPOSE 8000
CMD ["sh", "-c", "uv run --no-sync uvicorn benthos_api.main:app --host 0.0.0.0 --port ${PORT:-8000}"]