-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (43 loc) · 1.5 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (43 loc) · 1.5 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
58
59
60
# Multi-stage Dockerfile for SIF Website
# Following SIF Deployment Standards v1.0
# Stage 1: Builder
FROM python:3.11-slim AS builder
WORKDIR /build
# Copy project files
COPY pyproject.toml README.md ./
COPY src/ src/
# Install build dependencies and build wheel
RUN pip install --no-cache-dir build && \
python -m build
# Stage 2: Production
FROM python:3.11-slim
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 -s /bin/bash appuser
WORKDIR /app
# Copy wheel from builder and install
COPY --from=builder /build/dist/*.whl /tmp/
RUN pip install --no-cache-dir /tmp/*.whl && \
rm /tmp/*.whl
# Copy static assets and templates
COPY --chown=appuser:appuser static/ static/
COPY --chown=appuser:appuser templates/ templates/
# Copy SIF docs (baked into container - no volume mounts needed)
# These are the SIF Foundation content pages (about, research, contact)
COPY --chown=appuser:appuser docs/ docs/
# Set docs path environment variable
ENV SIL_DOCS_PATH=/app/docs
# Create logs directory
RUN mkdir -p /app/logs && chown appuser:appuser /app/logs
# Switch to non-root user
USER appuser
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Run application
CMD ["uvicorn", "sil_web.app:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"]