-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (35 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
48 lines (35 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
43
44
45
46
47
48
FROM python:3.12-slim-bookworm
WORKDIR /app
# Install system dependencies needed for xmlsec and cryptography
RUN apt-get update && apt-get install -y \
gcc \
curl \
libxml2-dev \
libxmlsec1-dev \
libxmlsec1-openssl \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY *.py .
# Copy migrations directory
COPY migrations/ migrations/
# Copy templates directory for PDF receipts
COPY templates/ templates/
# Copy fonts directory for PDF generation
COPY fonts/ fonts/
# Make migration script executable
RUN chmod +x migrate.py
# Set default environment variables for Gunicorn
ENV GUNICORN_WORKERS=2
ENV GUNICORN_TIMEOUT=60
# Create non-root user
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 8000
# Health check configuration
HEALTHCHECK --interval=60s --timeout=10s --retries=3 --start-period=10s \
CMD curl -f http://localhost:8000/health || exit 1
CMD ["sh", "-c", "python migrate.py && gunicorn --bind 0.0.0.0:8000 --workers $GUNICORN_WORKERS --timeout $GUNICORN_TIMEOUT app:app"]