-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (33 loc) · 950 Bytes
/
Dockerfile
File metadata and controls
45 lines (33 loc) · 950 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
36
37
38
39
40
41
42
43
44
45
FROM python:3.14-alpine
# Install system dependencies
RUN apk add --no-cache --update \
postgresql-dev \
gcc \
musl-dev \
netcat-openbsd \
&& rm -rf /var/cache/apk/*
# Install uv for fast Python package management
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
# Set up application directory
WORKDIR /app
# Copy dependency files first for better layer caching
COPY pyproject.toml ./
# Install dependencies
RUN uv sync
# Create non-root user for security
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
# Change ownership of the app directory
RUN chown -R appuser:appgroup /app
# Switch to non-root user
USER appuser
# Copy application code
COPY --chown=appuser:appgroup . .
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PATH="/app/.venv/bin:$PATH"
ENV VIRTUAL_ENV="/app/.venv"
# Expose port
EXPOSE 8000
# Run the application
CMD ["sh", "entrypoints/django.sh"]