forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
148 lines (108 loc) · 3.71 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
FROM python:3.6-alpine as base
#
# USAGE:
# cd sercices/director
# docker build -f Dockerfile -t director:prod --target production ../../
# docker run director:prod
#
# REQUIRED: context expected at ``osparc-simcore/`` folder because we need access to osparc-simcore/packages
LABEL maintainer=sanderegg
# simcore-user uid=8004(scu) gid=8004(scu) groups=8004(scu)
RUN adduser -D -u 8004 -s /bin/sh -h /home/scu scu
RUN apk add --no-cache \
su-exec
ENV PATH "/home/scu/.local/bin:$PATH"
# All SC_ variables are customized
ENV SC_PIP pip3 --no-cache-dir
ENV SC_BUILD_TARGET base
# TODO: update environs
ENV REGISTRY_AUTH = ''
ENV REGISTRY_USER = ''
ENV REGISTRY_PW = ''
ENV REGISTRY_URL = ''
ENV PUBLISHED_HOST_NAME=''
ENV EXTRA_HOSTS_SUFFIX = 'undefined'
EXPOSE 8080
# -------------------------- Build stage -------------------
# Installs build/package management tools and third party dependencies
#
# + /build WORKDIR
#
FROM base as build
ENV SC_BUILD_TARGET build
RUN apk add --no-cache \
gcc \
libc-dev \
git
RUN $SC_PIP install --upgrade \
pip \
wheel \
setuptools
WORKDIR /build
# install base 3rd party dependencies
COPY --chown=scu:scu services/director/requirements/*.txt \
tmp/director/requirements/
RUN $SC_PIP install \
-r tmp/director/requirements/base.txt
#--------------------------Cache stage -------------------
# CI in master buils & pushes this target to speed-up image build
#
# + /build
# + services/director [scu:scu] WORKDIR
#
FROM build as cache
ENV SC_BUILD_TARGET cache
COPY --chown=scu:scu packages/service-library /build/packages/service-library
COPY --chown=scu:scu services/director /build/services/director
# FIXME:
# necessary to prevent duplicated files.
# Will be removed when director is refactored using cookiecutter as this will not be necessary anymore
COPY --chown=scu:scu api/specs/shared/schemas/node-meta-v0.0.1.json /build/services/director/src/simcore_service_director/oas3/v0/schemas/node-meta-v0.0.1.json
WORKDIR /build/services/director
RUN $SC_PIP install -r requirements/prod.txt &&\
$SC_PIP list -v
# --------------------------Production stage -------------------
# Final cleanup up to reduce image size and startup setup
# Runs as scu (non-root user)
#
# + /home/scu $HOME = WORKDIR
# + services/director [scu:scu]
#
FROM cache as production
ENV SC_BUILD_TARGET production
ENV SC_BOOT_MODE production
WORKDIR /home/scu
RUN mkdir -p services/director &&\
chown scu:scu services/director &&\
mv /build/services/director/docker services/director/docker &&\
rm -rf /build
RUN apk del --no-cache\
gcc \
git
HEALTHCHECK --interval=30s \
--timeout=120s \
--start-period=30s \
--retries=3 \
CMD ["python3", "/home/scu/services/director/docker/healthcheck.py", "http://localhost:8080/v0/"]
ENTRYPOINT [ "/bin/sh", "services/director/docker/entrypoint.sh" ]
CMD ["/bin/sh", "services/director/docker/boot.sh"]
# --------------------------Development stage -------------------
# Source code accessible in host but runs in container
# Runs as scu with same gid/uid as host
# Placed at the end to speed-up the build if images targeting production
#
# + /devel WORKDIR
# + services (mounted volume)
#
FROM build as development
ENV SC_BUILD_TARGET development
ENV SC_BOOT_MODE development
# WORKDIR /build
# NOTE: can copy from /build if necessary
WORKDIR /devel
VOLUME /devel/packages
VOLUME /devel/services/director/
VOLUME /devel/services/api
ENV NODE_SCHEMA_LOCATION ../../../api/specs/shared/schemas/node-meta-v0.0.1.json
ENTRYPOINT [ "/bin/sh", "services/director/docker/entrypoint.sh" ]
CMD ["/bin/sh", "services/director/docker/boot.sh"]