-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (26 loc) · 1014 Bytes
/
Dockerfile
File metadata and controls
35 lines (26 loc) · 1014 Bytes
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
# SilkWeb API — Production Dockerfile
# Multi-stage build for minimal attack surface
FROM python:3.12-slim AS base
# Security: run as non-root user
RUN groupadd -r silkweb && useradd -r -g silkweb -d /app -s /sbin/nologin silkweb
WORKDIR /app
# Install system dependencies for argon2
RUN apt-get update && \
apt-get install -y --no-install-recommends libffi-dev && \
rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY api/ ./api/
COPY migrations/ ./migrations/
COPY alembic.ini .
# Switch to non-root user
USER silkweb
# Health check
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD python -c "import httpx; httpx.get('http://localhost:8000/health').raise_for_status()"
# Run with production settings
EXPOSE 8000
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "--no-access-log"]