-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (46 loc) · 1.73 KB
/
Dockerfile
File metadata and controls
66 lines (46 loc) · 1.73 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
# Multi-stage build for optimized production image (self-contained for Nextflow)
FROM python:3.10-slim AS builder
WORKDIR /build
# Build deps only in builder
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
make \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
# Install dependencies into a relocatable user site dir
RUN pip install --no-cache-dir --user -r requirements.txt
FROM python:3.10-slim AS runtime
LABEL maintainer="ESDP Team"
LABEL description="Early Stop Decision Polishing - Production ML Service"
LABEL version="1.0.2"
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
MODEL_PATH=/app/models/best_model_pipeline.pkl \
PORT=8000 \
LOG_LEVEL=INFO \
WORKERS=1
# Non-root user
RUN useradd -m -u 1000 esdp && \
mkdir -p /app /app/models /app/logs && \
chown -R esdp:esdp /app
WORKDIR /app
# Copy installed Python packages from builder
COPY --from=builder /root/.local /home/esdp/.local
ENV PATH=/home/esdp/.local/bin:$PATH
# Copy application code
COPY --chown=esdp:esdp esdp_decide.py .
COPY --chown=esdp:esdp api_service.py .
COPY --chown=esdp:esdp config.yaml .
COPY --chown=esdp:esdp docker-entrypoint.sh .
# Copy the model INTO the image for portability (Nextflow)
COPY --chown=esdp:esdp models/best_model_pipeline.pkl ./models/
# Delete the lines that is not necessary
RUN chmod +x /app/docker-entrypoint.sh
USER esdp
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health', timeout=5).read()"
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["uvicorn", "api_service:app", "--host", "0.0.0.0", "--port", "8000"]