Skip to content

Commit f16f9d8

Browse files
author
Kyle Spengler
committed
feat: add Docker image and container usage
1 parent ce5df24 commit f16f9d8

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Dockerfile

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
FROM python:3.11-slim
2+
3+
# 1) base setup
24
WORKDIR /app
35
COPY requirements.txt .
46
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
# 2) copy source
59
COPY serving_app ./serving_app
6-
COPY training ./training
7-
RUN python -m training.train || true
10+
COPY training ./training
11+
12+
# 3) model artifact location (inside the image)
13+
ENV MODEL_PATH=/app/models/model.pkl
14+
RUN mkdir -p /app/models
15+
16+
# 4) train during build so the model is baked into the image
17+
RUN python -m training.train
18+
19+
# 5) runtime config
820
ENV PORT=8000
921
EXPOSE 8000
10-
CMD ["uvicorn","serving_app.main:app","--host","0.0.0.0","--port","8000"]
22+
23+
# 6) single CMD that respects $PORT
24+
CMD ["sh", "-c", "uvicorn serving_app.main:app --host 0.0.0.0 --port ${PORT:-8000}"]
25+

0 commit comments

Comments
 (0)