-
Notifications
You must be signed in to change notification settings - Fork 488
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (38 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
50 lines (38 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
46
47
48
49
50
FROM python:3.13.2-slim
# Set working directory
WORKDIR /app
# Set non-sensitive environment variables
ARG APP_ENV=production
ENV APP_ENV=${APP_ENV} \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
&& pip install --upgrade pip \
&& pip install uv \
&& rm -rf /var/lib/apt/lists/*
# Copy pyproject.toml first to leverage Docker cache
COPY pyproject.toml .
RUN uv venv && . .venv/bin/activate && uv pip install -e .
# Copy the application
COPY . .
# Make entrypoint script executable - do this before changing user
RUN chmod +x /app/scripts/docker-entrypoint.sh
# Create a non-root user
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser
# Create log directory
RUN mkdir -p /app/logs
# Default port
EXPOSE 8000
# Log the environment we're using
RUN echo "Using ${APP_ENV} environment"
# Command to run the application
ENTRYPOINT ["/app/scripts/docker-entrypoint.sh"]
CMD ["/app/.venv/bin/uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]