-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile-mt-model
69 lines (52 loc) · 2.32 KB
/
Dockerfile-mt-model
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright 2022 ETH Zurich, Media Technology Center
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM nvidia/cuda:11.6.2-devel-ubuntu18.04 as base-gpu
ENV PATH /opt/conda/bin:$PATH
# Update & install packages
RUN apt-get update && \
apt-get install -y bzip2 ca-certificates wget curl git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
SHELL ["/bin/bash", "-c"]
WORKDIR /app
# Install latest miniconda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-py37_4.10.3-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda clean -tipsy && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc
# Set python env vars
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
FROM base-gpu as build
# Copy & install dependency files
COPY mt-model/requirements.txt .
RUN pip install -r requirements.txt --ignore-installed ruamel.yaml # ruamel.yaml: Dependency conflict within huggingface
# Copy ape libraries
COPY ape-model ./ape-model
COPY mtc_ape_web_editor ./mtc-ape-web-editor/mtc_ape_web_editor
COPY setup.py ./mtc-ape-web-editor/
RUN pip install ./ape-model --use-feature=in-tree-build && \
pip install ./mtc-ape-web-editor --use-feature=in-tree-build && \
rm -rf ape-model && rm -rf mtc-ape-web-editor
# Copy source code
COPY mt-model .
CMD [ "gunicorn", "-c", "gunicorn.conf.py", "--chdir", "mtc_mt_api", "-k", "uvicorn.workers.UvicornWorker", "app:app" ]
### Debug image with additional dependencies & debug entrypoint ###
FROM build as debug-gpu
ENV DEBUG=True
EXPOSE 5678
FROM build as test
CMD [ "python", "-m", "unittest", "mtc_mt_api.tests.test_integration" ]
### Production image ###
FROM build as prod-gpu