-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (33 loc) Β· 1.19 KB
/
Dockerfile
File metadata and controls
42 lines (33 loc) Β· 1.19 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
# Use an official Python runtime as a parent image
FROM python:3.9-slim-bookworm
# Set the working directory in the container
WORKDIR /app
# Prevent python from writing pyc files to disc and buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Install system dependencies needed for WeasyPrint (PDF generation)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
python3-dev \
python3-cffi \
libcairo2 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libgdk-pixbuf-2.0-0 \
libffi-dev \
shared-mime-info \
&& rm -rf /var/lib/apt/lists/*
# Install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# Create a non-root user and set permissions
RUN addgroup --system nonroot && adduser --system --ingroup nonroot nonroot
RUN chown -R nonroot:nonroot /app
USER nonroot
# Expose the port the app runs on
EXPOSE 80
ENTRYPOINT ["sh", "/app/entrypoint.sh"]
# Command to run the application in production
CMD ["gunicorn", "wsgi:app", "-b", "0.0.0.0:80", "--worker-class", "gthread", "--workers", "2", "--threads", "4", "--timeout", "120"]