-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (26 loc) · 861 Bytes
/
Copy pathDockerfile
File metadata and controls
35 lines (26 loc) · 861 Bytes
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
ARG UV_IMAGE=ghcr.io/astral-sh/uv:latest
FROM ${UV_IMAGE} AS uv
FROM python:3.12-slim
WORKDIR /app
# Install uv from the official uv image. Pin UV_IMAGE to a tag or digest for
# reproducible builds.
COPY --from=uv /uv /uvx /usr/local/bin/
# Copy all source files
COPY src ./src
COPY api ./api
COPY pyproject.toml ./
# Create a virtual environment and install in editable mode (without dev dependencies)
RUN uv venv /app/.venv \
&& uv pip install --editable .
# Set environment variables
ENV PYTHONPATH=/app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PATH="/app/.venv/bin:$PATH"
# Create non-root user after everything is set up
RUN useradd -m -u 1000 appuser
USER appuser
# Expose port
EXPOSE 8000
# Default command: run the FastAPI server
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"]