-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
29 lines (22 loc) · 901 Bytes
/
Dockerfile
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
FROM python:3.10 AS builder
# install hatch
RUN pip install --no-cache-dir --upgrade hatch
COPY . /code
# build python package
WORKDIR /code
RUN hatch build -t wheel
FROM python:3.10 as main
# copy wheel package from stage 1
COPY --from=builder /code/dist /code/dist
RUN pip install --no-cache-dir --upgrade /code/dist/*
# force download of models
RUN python -c 'from optimum.onnxruntime import ORTModelForSequenceClassification;\
model = ORTModelForSequenceClassification.from_pretrained("dcferreira/detoxify-optimized")'
RUN python -c 'from transformers import pipeline;\
model_path = "cardiffnlp/twitter-xlm-roberta-base-sentiment";\
sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)'
# copy the serving code and our database
COPY app.py /code
# run web server
WORKDIR /code
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]