-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (46 loc) · 1.76 KB
/
Copy pathDockerfile
File metadata and controls
59 lines (46 loc) · 1.76 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
FROM prom/prometheus:latest AS prometheus-bin
FROM python:3.10-slim-bookworm
# Set working directory
WORKDIR /app
# Runtime defaults
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=120 \
PIP_RETRIES=20
# Copy requirements file
COPY requirements.txt .
# Install dependencies (will include spacy, presidio, prometheus-client, etc.)
RUN set -eux; \
for i in 1 2 3 4 5; do \
pip install --retries 20 --timeout 120 -r requirements.txt && break; \
echo "pip install failed (attempt ${i}/5), retrying..."; \
if [ "$i" -eq 5 ]; then exit 1; fi; \
sleep $((i * 10)); \
done
# Download Spacy model
RUN set -eux; \
for i in 1 2 3 4 5; do \
python -m spacy download en_core_web_lg && break; \
echo "spaCy model download failed (attempt ${i}/5), retrying..."; \
if [ "$i" -eq 5 ]; then exit 1; fi; \
sleep $((i * 10)); \
done
# Copy application code
COPY . .
# Copy Prometheus binary from official image so one container can run
# API + metrics scraper for native UI observability.
COPY --from=prometheus-bin /bin/prometheus /usr/local/bin/prometheus
# Ensure runtime directories exist inside container
RUN mkdir -p uploads output quarantine artifacts audit
# Startup script launches Prometheus in background and API in foreground.
COPY docker/start.sh /app/docker/start.sh
RUN chmod +x /app/docker/start.sh
# Expose FastAPI port
EXPOSE 8001
EXPOSE 9090
HEALTHCHECK --interval=30s --timeout=5s --start-period=40s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8001/', timeout=3)"
# Run the app
CMD ["/app/docker/start.sh"]