fix: don't use adduser and addgroup for docker images (#3344)

* fix: don't use adduser and addgroup for docker images

* Revert "fix: Remove alternative image architectures until we virtualize (#3336)"

This reverts commit 00c5116a2e.
This commit is contained in:
Dean Sheather
2022-08-01 19:28:38 +00:00
committed by GitHub
parent 8f3727d05d
commit 66a5b0f7bc
3 changed files with 31 additions and 14 deletions
+10 -6
View File
@@ -1,4 +1,8 @@
FROM alpine
# This is the multi-arch Dockerfile used for Coder. Since it's multi-arch and
# cross-compiled, it cannot have ANY "RUN" commands. All binaries are built
# using the go toolchain on the host and then copied into the build context by
# scripts/build_docker.sh.
FROM alpine:latest
# LABEL doesn't add any real layers so it's fine (and easier) to do it here than
# in the build script.
@@ -11,12 +15,12 @@ LABEL \
org.opencontainers.image.version="$CODER_VERSION" \
org.opencontainers.image.licenses="AGPL-3.0"
# Create coder group and user. We cannot use `addgroup` and `adduser` because
# they won't work if we're building the image for a different architecture.
COPY --chown=root:root --chmod=644 group passwd /etc/
# The coder binary is injected by scripts/build_docker.sh.
ADD coder /opt/coder
COPY --chown=coder:coder --chmod=755 coder /opt/coder
# Create coder group and user.
RUN addgroup -g 1000 coder && \
adduser -D -g "" -h /home/coder -G coder -u 1000 -S -s /bin/sh coder
USER coder:coder
ENTRYPOINT [ "/opt/coder", "server" ]