-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (25 loc) · 1.06 KB
/
Copy pathDockerfile
File metadata and controls
34 lines (25 loc) · 1.06 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
# One image, two entry points. The API and the dashboard share every dependency
# except Streamlit's, and building twice to save a few megabytes would mean two
# images that can drift apart. The compose file picks the command.
FROM python:3.12-slim AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# Dependencies first: this layer is cached until requirements.txt changes, so
# editing source does not reinstall scikit-learn.
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY pyproject.toml ./
COPY src/ ./src/
RUN pip install --no-cache-dir --no-deps -e .
COPY app.py ./
COPY .streamlit/ ./.streamlit/
COPY models/ ./models/
COPY data/users.csv data/videos.csv ./data/
# Run as a non-root user. Nothing here needs to write to the image.
RUN useradd --create-home --uid 10001 appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 8000 8501
# Overridden by compose; this default makes `docker run` produce the API.
CMD ["uvicorn", "model_info.api:app", "--host", "0.0.0.0", "--port", "8000"]