diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2022-04-10 11:55:11 +0200 |
---|---|---|
committer | Bastien Wirtz <bastien.wirtz@gmail.com> | 2022-04-30 15:39:36 +0200 |
commit | 049f85221e945b90bf87d21afe4d306839d65740 (patch) | |
tree | 1288ab580f2a274df8b507e2bbe37e2ff03c70ca /Dockerfile | |
parent | cd75da69f9e57c3fe0f63c3ed6def0577d75a47c (diff) | |
download | homer-049f85221e945b90bf87d21afe4d306839d65740.tar.gz homer-049f85221e945b90bf87d21afe4d306839d65740.tar.zst homer-049f85221e945b90bf87d21afe4d306839d65740.zip |
Simplify the container starting process to allow it to run with a
unprivileged user
Diffstat (limited to 'Dockerfile')
-rw-r--r-- | Dockerfile | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -12,24 +12,28 @@ RUN yarn build | |||
12 | # production stage | 12 | # production stage |
13 | FROM alpine:3.15 | 13 | FROM alpine:3.15 |
14 | 14 | ||
15 | ENV USER lighttpd | 15 | ENV GID 1000 |
16 | ENV GROUP lighttpd | 16 | ENV UID 1000 |
17 | ENV GID 911 | ||
18 | ENV UID 911 | ||
19 | ENV PORT 8080 | 17 | ENV PORT 8080 |
20 | ENV SUBFOLDER "/_" | 18 | ENV SUBFOLDER "/_" |
19 | ENV INIT_ASSETS 1 | ||
21 | 20 | ||
22 | RUN addgroup -S ${GROUP} -g ${GID} && adduser -D -S -u ${UID} ${USER} ${GROUP} && \ | 21 | RUN addgroup -S lighttpd -g ${GID} && adduser -D -S -u ${UID} lighttpd lighttpd && \ |
23 | apk add -U --no-cache lighttpd | 22 | apk add -U --no-cache lighttpd |
24 | 23 | ||
25 | COPY entrypoint.sh /entrypoint.sh | 24 | WORKDIR /www |
26 | COPY lighttpd.conf /lighttpd.conf | ||
27 | 25 | ||
28 | COPY --from=build-stage --chown=${USER}:${GROUP} /app/dist /www/ | 26 | COPY lighttpd.conf /lighttpd.conf |
27 | COPY entrypoint.sh /entrypoint.sh | ||
28 | COPY --from=build-stage --chown=${UID}:${GID} /app/dist /www/ | ||
29 | COPY --from=build-stage --chown=${USER}:${GROUP} /app/dist/assets /www/default-assets | 29 | COPY --from=build-stage --chown=${USER}:${GROUP} /app/dist/assets /www/default-assets |
30 | |||
31 | USER ${UID}:${GID} | ||
32 | |||
30 | HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ | 33 | HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ |
31 | CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:${PORT}/ || exit 1 | 34 | CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:${PORT}/ || exit 1 |
32 | 35 | ||
33 | EXPOSE ${PORT} | 36 | EXPOSE ${PORT} |
34 | VOLUME /www/assets | 37 | VOLUME /www/assets |
38 | |||
35 | ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] | 39 | ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] |