-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
29 lines (22 loc) · 1005 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.7-slim
RUN addgroup --gid 1001 "elg" && \
adduser --disabled-password --gecos "ELG User,,," \
--home /elg --ingroup elg --uid 1001 elg && \
mkdir /elg/workdir && \
chmod -R +x /elg/
# Copy in our app, its requirements file and the entrypoint script
COPY --chown=elg:elg serve.py docker-entrypoint.sh init_model.py /elg/
RUN chmod +x /elg/docker-entrypoint.sh && \
chmod +x /elg/serve.py && chmod -R +x /elg/
# Everything from here down runs as the unprivileged user account
USER elg:elg
EXPOSE 8866
WORKDIR /elg/
# Create a Python virtual environment for the dependencies
RUN python -mvenv venv && \
/elg/venv/bin/python -m pip install --upgrade pip && \
venv/bin/pip --no-cache-dir install flask==2.0.2 flask_json==0.3.4 transformers==4.12.0 numpy==1.21.3 scipy==1.6.1 torch==1.10.0
ENV WORKERS=1
CMD ["/elg/venv/bin/python", "serve.py"]
RUN ["/elg/venv/bin/python", "-c", "from init_model import Initializer; Initializer()"]
ENV TRANSFORMERS_OFFLINE=1