-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (32 loc) · 1.07 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (32 loc) · 1.07 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.13.2-slim
WORKDIR /app
# Set non-sensitive environment variables
ARG APP_ENV=production
ENV APP_ENV=${APP_ENV} \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PYTHONDONTWRITEBYTECODE=1 \
UV_SYSTEM_PYTHON=1
# Copy uv binary from official container
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install dependencies (without installing the project itself)
RUN --mount=type=cache,id=uv-cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev
# Copy application code
COPY app/ ./app/
# Install the project
RUN --mount=type=cache,id=uv-cache,target=/root/.cache/uv \
uv sync --frozen --no-dev
# Create a non-root user
RUN useradd -m -u 1000 appuser && \
chown -R appuser:appuser /app
USER appuser
# Create log directory
RUN mkdir -p /app/logs
# Default port
EXPOSE 8000
# Command to run the application with multiple workers
CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4"]