-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.brain
More file actions
45 lines (30 loc) · 1.2 KB
/
Copy pathDockerfile.brain
File metadata and controls
45 lines (30 loc) · 1.2 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
40
41
42
43
44
45
FROM python:3.12-slim AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /app
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never
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-dev --no-install-project
COPY src/ ./src/
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-dev
FROM python:3.12-slim AS runtime
RUN groupadd -g 1001 appgroup && \
useradd -u 1001 -g appgroup -m -d /app -s /bin/false appuser
WORKDIR /app
COPY --from=builder --chown=appuser:appgroup /app /app
# Pre-create the storage directory owned by appuser.
# Docker initialises a named volume from the image on first mount, so this
# ensures the volume is writable by the non-root user right away.
RUN mkdir -p /data && chown appuser:appgroup /data
# Put the venv on PATH so a2c-brain resolves directly.
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 50051
EXPOSE 50052
USER appuser
CMD ["a2c-brain"]