-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (32 loc) · 1.21 KB
/
Copy pathDockerfile
File metadata and controls
44 lines (32 loc) · 1.21 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
# syntax=docker/dockerfile:1
FROM python:3.12-slim
# the deployment platform's HTTP healthcheck uses curl/wget inside the container.
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
# Install uv
RUN pip install uv
WORKDIR /app
# Copy dependency manifest first (layer-cache friendly)
COPY pyproject.toml README.md ./
# Copy source
COPY red_transporte_api/ ./red_transporte_api/
# Install dependencies as root. Packages are bundled in /app/.venv.
RUN uv sync --extra api --no-dev --no-editable
# Create non-root user and pre-create /data directories with correct ownership.
# This must happen as root (before USER app) so chown works.
# Named volumes inherit build-time ownership on first init;
# the entrypoint also runs mkdir -p as a safety net for existing volumes.
RUN groupadd --system app \
&& useradd --system --gid app --home /app app \
&& mkdir -p /data/.cache/uv \
&& chown -R app:app /data
# Copy and prepare entrypoint (still root at this point)
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
USER app
ENV UV_CACHE_DIR=/data/.cache/uv
ENV HOME=/data
ENV RED_TRANSPORTE_DATA_DIR=/data
EXPOSE 8000
ENTRYPOINT ["/entrypoint.sh"]