-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile-ape-model
67 lines (49 loc) · 2.17 KB
/
Dockerfile-ape-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
# 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 ape-model/requirements.txt .
RUN pip install -r requirements.txt
COPY mtc_ape_web_editor ./mtc-ape-web-editor/mtc_ape_web_editor
COPY setup.py ./mtc-ape-web-editor/
RUN pip install ./mtc-ape-web-editor --use-feature=in-tree-build && \
rm -rf mtc-ape-web-editor
# Copy source code
COPY ape-model .
CMD [ "gunicorn", "-c", "./mtc_ape_api/gunicorn.conf.py", "--chdir", "mtc_ape_api", "-k", "uvicorn.workers.UvicornWorker", "app:api" ]
### Debug image with additional dependencies & debug entrypoint ###
FROM build as debug-gpu
ENV DEBUG=True
FROM build as test
CMD [ "python", "-m", "unittest", "discover", "--buffer", "--verbose" ]
### Production image ###
FROM build as prod-gpu
# Start server
# Only ever start one worker, parallelize with horizontally scaling containers