-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
80 lines (62 loc) · 2.09 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
# build with
# docker build -t snana-summary-webserver .
#
# run with
# docker run -d --name snana-summary -p 8080:8080 snana-summary-webserver
#
# To bind-mount the source directory for testing purposes, after -d:
# --mount type=bind,source=$PWD,target=/code
#
# For this to work, you need to drop a symbolic link in static:
# cd static
# ln -s ../rkwebutil/rkwebutil.js rkwebutil.js
#
# To bind-mount an external data dir, also add:
# --mount type=bind,source=<datadir>,target=/data \
#
# So the command for both, run from here, might be:
#
# docker run -d --name snana-summary -p 8080:8080 \
# --mount type=bind,source=$PWD,target=/code \
# --mount type=bind,source=$PWD/data,target=/data \
# snana-summary-webserver
#
# where <datadir> is where the .pkl files exported from
# lib/parse_snana.py live (perhaps $PWD/data).
#
FROM rknop/devuan-daedalus-rknop AS base
MAINTAINER Rob Knop <[email protected]>
SHELL [ "/bin/bash", "-c" ]
RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" apt-get -y upgrade \
&& DEBIAN_FRONTEND="noninteractive" TZ="US/Pacific" apt-get -y install -y \
python3 python3-venv \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# ======================================================================
# pip installs a full dev environment, which we don't want
# in our final image. (400 unnecessary MB.)
FROM base AS build
RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y python3-pip
RUN mkdir /venv
RUN python3 -mvenv /venv
RUN source /venv/bin/activate \
&& pip install \
gunicorn flask pyyaml numpy pandas matplotlib astropy
RUN mkdir /tmp/build
RUN mkdir /code
COPY . /tmp/build
WORKDIR /tmp/build
RUN make INSTALLDIR=/code install
# ======================================================================
FROM base AS final
COPY --from=build /venv/ /venv/
ENV PATH=/venv/bin:$PATH
COPY --from=build /code/ /code/
WORKDIR /code
COPY data /data
RUN mkdir /snana_sim
CMD [ "gunicorn", "-w", "4", "-b", "0.0.0.0:8080", "--timeout", "0", \
"webservice:app" ]