-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
88 lines (64 loc) · 2.62 KB
/
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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
FROM python:3.6.8-slim
RUN export DEBIAN_FRONTEND=noninteractive \
&& echo "LC_ALL=en_US.UTF-8" >> /etc/environment \
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& echo "LANG=en_US.UTF-8" > /etc/locale.conf \
&& apt-get update && apt-get install -y locales \
&& locale-gen en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --upgrade pip \
&& pip install https://download.pytorch.org/whl/cpu/torch-1.1.0-cp36-cp36m-linux_x86_64.whl \
https://download.pytorch.org/whl/cpu/torchvision-0.3.0-cp36-cp36m-linux_x86_64.whl \
matplotlib==3.0.3 \
&& rm -rf /root/.cache/pip
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8
# add user webapp
RUN useradd -ms /bin/bash webapp
WORKDIR /home
# pip libraries
COPY requirements.txt requirements.txt
#RUN pip install torch torchvision
RUN pip install -r requirements.txt --no-deps
# copy files and change execution permission of entrypoint
COPY webapp webapp
WORKDIR webapp
# secret key is needed to keep the client-side sessions secure
RUN mkdir -p instance
RUN head -c 24 /dev/urandom > instance/secret_key
# download the weights for pnasnet5 from github release
RUN echo 'downloading image-classifier weights'
# Image Classification
# Pytorch
#ENV CLASSIFICATIONLIBRARY pytorch
# pnasnet-5, requires quite some ram and cpu
#ADD https://gitreleases.dev/gh/cozyDoomer/deep-learning-webapp/latest/pnasnet5.pth static/weights/pnasnet5.pth
#ENV NNET PnasNet5
# Resnet-152
#ADD https://download.pytorch.org/models/resnet152-b121ed2d.pth static/weights/resnet152.pth
#ENV NNET ResNet152
# Resnet-50
#ADD https://download.pytorch.org/models/resnet50-19c8e357.pth static/weights/resnet50.pth
#ENV NNET ResNet50
# fastai
ENV CLASSIFICATION-LIBRARY fastai
# Inception-Resnetv2
ADD https://gitreleases.dev/gh/cozyDoomer/deep-learning-webapp/latest/inceptionresnetv2.pkl static/weights/inceptionresnetv2.pkl
ENV NNET InceptionResNetv2
# Object Detection
# RetinaNet with ResNet-34 backbone
ADD https://gitreleases.dev/gh/cozyDoomer/deep-learning-webapp/latest/retinanet_resnet34.pkl static/weights/retinanet_resnet34.pkl
# alternatively download the weights for one model with the links above
# store them in webapp/static/weights/<model>.pth in the local repository
# (keep the <100MB single file limit of github in mind) and copy with this:
#COPY webapp/static/weights/<model>.pth webapp/static/weights/<model>.pth
ENV FLASK_APP main.py
ENV PYTHONUNBUFFERED TRUE
#recursive chown on file system for the webapp user
RUN chown -R webapp:webapp ./
USER webapp
EXPOSE 8080
ENV PORT 8080
CMD gunicorn -c static/conf/gunicorn_config.py main:app
#ENTRYPOINT ["./boot.sh"]