-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
81 lines (61 loc) · 2.16 KB
/
Dockerfile
File metadata and controls
81 lines (61 loc) · 2.16 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
70
71
72
73
74
75
76
77
78
79
80
81
# --- Stage 1: Builder ---
FROM python:3.11-slim AS builder
LABEL maintainer="KidSearch Team"
LABEL description="Builder stage for KidSearch dependencies"
WORKDIR /app
# Installer les outils minimaux nécessaires à la compilation de certaines libs (comme curl_cffi)
RUN apt-get update && apt-get install -y --no-install-recommends build-essential curl && \
rm -rf /var/lib/apt/lists/*
# Créer l'environnement virtuel
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copier les requirements
COPY requirements.txt .
# Installer les dépendances
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir -r requirements.txt
# --- Stage 2: Final Image ---
FROM python:3.11-slim
LABEL maintainer="KidSearch Team"
LABEL description="KidSearch Dashboard & API - Safe search engine for children"
WORKDIR /app
# Installer tini pour la gestion des signaux et curl pour le healthcheck
RUN apt-get update && apt-get install -y --no-install-recommends tini curl && \
rm -rf /var/lib/apt/lists/*
# Copier l'environnement virtuel depuis le builder
COPY --from=builder /opt/venv /opt/venv
# Copier le code source
COPY kidsearch/ ./kidsearch
COPY dashboard/ ./dashboard
COPY start.py .
COPY api.py .
COPY crawler.py .
COPY run_api.py .
# Activer le venv
ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1
# Créer répertoires nécessaires
RUN mkdir -p data/logs config && \
touch dashboard/__init__.py && \
touch dashboard/src/__init__.py
# Nettoyage final des caches
RUN find /opt/venv -type d -name "__pycache__" -exec rm -rf {} + && \
find /opt/venv -type f -name "*.pyc" -delete && \
rm -rf /root/.cache /tmp/* /var/tmp/*
# Variables d'environnement de base
ENV SERVICE=all
ENV DASHBOARD_PORT=8501
ENV DASHBOARD_HOST=0.0.0.0
ENV API_PORT=8080
ENV API_HOST=0.0.0.0
ENV API_WORKERS=4
ENV API_ENABLED=true
ENV TYPESENSE_URL=http://typesense:8108
# Exposer les ports
EXPOSE 8501 8080
# Healthcheck
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8501/_stcore/health || exit 1
# Entrypoint
ENTRYPOINT ["/usr/bin/tini", "--", "python", "start.py"]
CMD ["--docker"]