-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (39 loc) · 1.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
FROM alpine AS alpine
FROM scratch as environment
ARG lang="en_US.UTF-8"
# change in childern:
ENV CONTAINERNAME "scratch"
ENV RUN_USER "somebody"
ENV RUN_GROUP "somebody"
ENV RUN_HOME "/home/somebody"
ENV BUILD_USER "coder"
ENV BUILD_GROUP "coder"
ENV BUILD_HOME "/home/coder"
ENV LANG "${lang}"
ENV SHARED_GROUP_NAME "shared-access"
ENV SHARED_GROUP_ID "500"
ENV PS1 '\[\033[36;1m\]\u\[\033[97m\]@\[\033[32m\]${CONTAINERNAME}[\[\033[36m\]\h\[\033[97m\]]:\[\033[37m\]\w\[\033[0m\]\$ '
ENV PKG_INSTALL "apk add --no-cache --clean-protected -u"
ENV PKG_REMOVE "apk del --no-cache --purge"
ENV PKG_SEARCH "apk search --no-cache"
ENV PKG_CLEANUP1 "apk del --no-cache busybox alpine-baselayout"
ENV PKG_CLEANUP2 "apk del --no-cache --purge apk-tools zlib alpine-keys"
ENV ALLOW_USER "chown -R ${RUN_USER}:${RUN_GROUP}"
ENV ALLOW_BUILD "chown -R ${BUILD_USER}:${BUILD_GROUP}"
FROM environment as user
COPY --from=alpine / /
RUN addgroup -g $SHARED_GROUP_ID $SHARED_GROUP_NAME
RUN addgroup "${RUN_GROUP}"
RUN adduser -S -D -G "${RUN_GROUP}" "${RUN_USER}"
RUN adduser ${RUN_USER} ${SHARED_GROUP_NAME}
RUN addgroup "${BUILD_GROUP}"
RUN adduser -S -D -G "${BUILD_GROUP}" "${BUILD_USER}"
FROM environment as production
COPY --from=user /etc/passwd /etc/passwd
COPY --from=user /etc/group /etc/group
COPY --from=user --chown=${RUN_USER} /home/${RUN_USER} /home/${RUN_USER}
COPY --from=user --chown=${BUILD_USER} /home/${BUILD_USER} /home/${BUILD_USER}
USER $RUN_USER
# allow derieved images to overwrite the language
ONBUILD ARG lang
ONBUILD ENV LANG=${lang:-${LANG}}