-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (42 loc) · 1.52 KB
/
Dockerfile
File metadata and controls
56 lines (42 loc) · 1.52 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
# Hardened Dockerfile for Authelia GUI v0.1
FROM python:3.11-slim-bookworm
# Prevent Python from writing pyc files and buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Set working directory
WORKDIR /app
# Install system dependencies including curl for healthcheck
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -g 1000 appuser && \
useradd -u 1000 -g appuser -s /bin/bash -m appuser
# Copy requirements first for better caching
COPY --chown=appuser:appuser requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY --chown=appuser:appuser app/ ./app/
COPY --chown=appuser:appuser templates/ ./templates/
COPY --chown=appuser:appuser static/ ./static/
# Create data directories with proper permissions
RUN mkdir -p /data/backups && \
chown -R appuser:appuser /data
# Switch to non-root user
USER appuser
# Set working directory to app
WORKDIR /app/app
# Set default PORT
ENV PORT=8080
# Expose port (configurable via PORT env var)
EXPOSE ${PORT}
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -fsS http://localhost:${PORT}/health || exit 1
# Run application (use shell form to allow env var substitution)
CMD sh -c "python -m uvicorn app:app --host 0.0.0.0 --port ${PORT}"