-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.fastapi
More file actions
34 lines (25 loc) · 979 Bytes
/
Copy pathDockerfile.fastapi
File metadata and controls
34 lines (25 loc) · 979 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
FROM python:3.11-slim-bookworm
WORKDIR /app
# Install system dependencies (minimal) and clean apt lists to reduce CVEs
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& update-ca-certificates
# Install Python dependencies
COPY requirements.fastapi.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Copy FastAPI application, Pydantic models, and shared logging
COPY src/ml_pipelines_kfp/iris_xgboost/pipelines/components/fastapi/fastapi_server.py main.py
COPY src/ml_pipelines_kfp/iris_xgboost/models/ models/
COPY src/ml_pipelines_kfp/log.py log.py
# Create and use non-root user
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser
# Set environment variables
ENV MODEL_PATH=/app/model_artifacts/model.joblib
ENV PORT=8080
ENV PYTHONPATH=/app
EXPOSE 8080
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]