-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (53 loc) · 1.85 KB
/
Copy pathDockerfile
File metadata and controls
69 lines (53 loc) · 1.85 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
61
62
63
64
65
66
67
68
69
# ============================================================
# WildGuard AI — Dockerfile
# Multi-stage build: builder (deps) → runtime (slim)
# Python 3.11-slim for minimal image size
# ============================================================
# -- Stage 1: Builder --
FROM python:3.11-slim AS builder
WORKDIR /build
# Install build deps for native extensions (mysql, pillow, etc.)
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libssl-dev \
libffi-dev \
default-libmysqlclient-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install --no-cache-dir --prefix=/install -r requirements.txt
# -- Stage 2: Runtime --
FROM python:3.11-slim AS runtime
LABEL maintainer="WildGuard AI <ops@wildguard.ai>"
LABEL version="1.0.0"
WORKDIR /app
# Runtime system deps only
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder
COPY --from=builder /install /usr/local
# Copy application code
COPY . .
# Create required directories
RUN mkdir -p uploads reports static/uploads
# Create non-root user for security
RUN addgroup --system wildguard && adduser --system --ingroup wildguard wildguard
RUN chown -R wildguard:wildguard /app
USER wildguard
# Expose Flask port
EXPOSE 5001
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5001/health')" || exit 1
# Start with Gunicorn (production WSGI server)
CMD ["gunicorn", \
"--bind", "0.0.0.0:5001", \
"--workers", "4", \
"--worker-class", "sync", \
"--timeout", "120", \
"--log-level", "info", \
"--access-logfile", "-", \
"--error-logfile", "-", \
"app:app"]