-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
70 lines (51 loc) · 1.9 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
FROM opencor/opencor:2021-01-13 as base
#
# USAGE:
# cd services/opencor
# docker build -f Dockerfile -t opencor:prod --target production ../../
# docker run opencor:prod
#
LABEL maintainer=KZzizzle
# simcore-user uid=8004(${SC_USER_NAME}) gid=8004(${SC_USER_NAME}) groups=8004(${SC_USER_NAME})
ENV SC_USER_ID 8004
ENV SC_USER_NAME scu
RUN adduser --uid ${SC_USER_ID} --disabled-password --gecos "" --shell /bin/sh --home /home/${SC_USER_NAME} ${SC_USER_NAME}
RUN apt-get update \
&& apt-get -y install --no-install-recommends \
jq \
&& rm --recursive --force /var/lib/apt/lists/*
# -------------------------- Build stage -------------------
# Installs build/package management tools and third party dependencies
#
# + /build WORKDIR
#
FROM base as build
ENV SC_BUILD_TARGET build
WORKDIR /build
# defines the output of the build
RUN mkdir --parents /build/bin
# --------------------------Production stage -------------------
# Final cleanup up to reduce image size and startup setup
# Runs as ${SC_USER_NAME} (non-root user)
#
# + /home/${SC_USER_NAME} $HOME = WORKDIR
# + opencor [${SC_USER_NAME}:${SC_USER_NAME}]
# + docker [${SC_USER_NAME}:${SC_USER_NAME}]
# + service.cli [${SC_USER_NAME}:${SC_USER_NAME}]
#
FROM base as production
ENV SC_BUILD_TARGET production
ENV SC_BOOT_MODE production
ENV INPUT_FOLDER="/input" \
OUTPUT_FOLDER="/output"
WORKDIR /home/${SC_USER_NAME}
# copy docker bootup scripts
COPY --chown=${SC_USER_NAME}:${SC_USER_NAME} docker/custom/*.sh docker/
# copy simcore service cli
COPY --chown=${SC_USER_NAME}:${SC_USER_NAME} service.cli/ service.cli/
# necessary to be able to call run directly without sh in front
ENV PATH="/home/${SC_USER_NAME}/service.cli:${PATH}"
# copy binaries from build
COPY --from=build --chown=${SC_USER_NAME}:${SC_USER_NAME} /build/bin opencor
ENTRYPOINT [ "/bin/sh", "docker/entrypoint.sh", "/bin/sh", "-c" ]
CMD ["run"]