-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.django
More file actions
57 lines (46 loc) · 1.3 KB
/
Dockerfile.django
File metadata and controls
57 lines (46 loc) · 1.3 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
51
52
53
54
55
56
57
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
netcat-openbsd \
sudo \
# Playwright browser dependencies
libglib2.0-0 \
libnss3 \
libatk-bridge2.0-0 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
libgbm1 \
libxss1 \
libasound2 \
libxfixes3 \
libcairo2 \
libpango-1.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
RUN mkdir logs
# Set environment variables.
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install -r requirements.txt
# Copy project files
COPY . .
# Create a non-root user to run the application.
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
RUN chown -R appuser:appgroup /app
RUN mkdir -p /app/logs && chown -R appuser:appgroup /app/logs
# Entrypoint to run migrations and collectstatic
RUN chmod +x /app/docker/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/app/docker/entrypoint.sh"]
# Keep running as root; entrypoint will drop privileges when executing app commands
# Expose the port the application runs on.
EXPOSE 8000
# Default command is handled by entrypoint (exec gunicorn)
CMD []