mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
+20
-7
@@ -95,14 +95,27 @@ ln -P Dockerfile "$temp_dir/"
|
||||
|
||||
cd "$temp_dir"
|
||||
|
||||
build_args=(
|
||||
--platform "$arch"
|
||||
--build-arg "CODER_VERSION=$version"
|
||||
--tag "$image_tag"
|
||||
)
|
||||
|
||||
log "--- Building Docker image for $arch ($image_tag)"
|
||||
docker buildx build "${build_args[@]}" . 1>&2
|
||||
|
||||
# Pull the base image, copy the /etc/group and /etc/passwd files out of it, and
|
||||
# add the coder group and user. We have to do this in a separate step instead of
|
||||
# using the RUN directive in the Dockerfile because you can't use RUN if you're
|
||||
# building the image for a different architecture than the host.
|
||||
docker pull --platform "$arch" alpine:latest 1>&2
|
||||
|
||||
temp_container_id="$(docker create --platform "$arch" alpine:latest)"
|
||||
docker cp "$temp_container_id":/etc/group ./group 1>&2
|
||||
docker cp "$temp_container_id":/etc/passwd ./passwd 1>&2
|
||||
docker rm "$temp_container_id" 1>&2
|
||||
|
||||
echo "coder:x:1000:coder" >>./group
|
||||
echo "coder:x:1000:1000::/:/bin/sh" >>./passwd
|
||||
|
||||
docker buildx build \
|
||||
--platform "$arch" \
|
||||
--build-arg "CODER_VERSION=$version" \
|
||||
--tag "$image_tag" \
|
||||
. 1>&2
|
||||
|
||||
cdroot
|
||||
rm -rf "$temp_dir"
|
||||
|
||||
Reference in New Issue
Block a user