File tree 3 files changed +31
-14
lines changed
3 files changed +31
-14
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ jobs:
102
102
103
103
# build and (maybe) push Docker images for each architecture
104
104
images=()
105
- for arch in amd64; do
105
+ for arch in amd64 armv7 arm64 ; do
106
106
img="$(
107
107
./scripts/build_docker.sh \
108
108
${{ (!github.event.inputs.dry_run && !github.event.inputs.snapshot) && '--push' || '' }} \
Original file line number Diff line number Diff line change 1
- FROM alpine
1
+ # This is the multi-arch Dockerfile used for Coder. Since it's multi-arch and
2
+ # cross-compiled, it cannot have ANY "RUN" commands. All binaries are built
3
+ # using the go toolchain on the host and then copied into the build context by
4
+ # scripts/build_docker.sh.
5
+ FROM alpine:latest
2
6
3
7
# LABEL doesn't add any real layers so it's fine (and easier) to do it here than
4
8
# in the build script.
@@ -11,12 +15,12 @@ LABEL \
11
15
org.opencontainers.image.version="$CODER_VERSION" \
12
16
org.opencontainers.image.licenses="AGPL-3.0"
13
17
18
+ # Create coder group and user. We cannot use `addgroup` and `adduser` because
19
+ # they won't work if we're building the image for a different architecture.
20
+ COPY --chown=root:root --chmod=644 group passwd /etc/
21
+
14
22
# The coder binary is injected by scripts/build_docker.sh.
15
- ADD coder /opt/coder
23
+ COPY --chown=coder:coder --chmod=755 coder /opt/coder
16
24
17
- # Create coder group and user.
18
- RUN addgroup -g 1000 coder && \
19
- adduser -D -g "" -h /home/coder -G coder -u 1000 -S -s /bin/sh coder
20
25
USER coder:coder
21
-
22
26
ENTRYPOINT [ "/opt/coder" , "server" ]
Original file line number Diff line number Diff line change @@ -95,14 +95,27 @@ ln -P Dockerfile "$temp_dir/"
95
95
96
96
cd " $temp_dir "
97
97
98
- build_args=(
99
- --platform " $arch "
100
- --build-arg " CODER_VERSION=$version "
101
- --tag " $image_tag "
102
- )
103
-
104
98
log " --- Building Docker image for $arch ($image_tag )"
105
- docker buildx build " ${build_args[@]} " . 1>&2
99
+
100
+ # Pull the base image, copy the /etc/group and /etc/passwd files out of it, and
101
+ # add the coder group and user. We have to do this in a separate step instead of
102
+ # using the RUN directive in the Dockerfile because you can't use RUN if you're
103
+ # building the image for a different architecture than the host.
104
+ docker pull --platform " $arch " alpine:latest 1>&2
105
+
106
+ temp_container_id=" $( docker create --platform " $arch " alpine:latest) "
107
+ docker cp " $temp_container_id " :/etc/group ./group 1>&2
108
+ docker cp " $temp_container_id " :/etc/passwd ./passwd 1>&2
109
+ docker rm " $temp_container_id " 1>&2
110
+
111
+ echo " coder:x:1000:coder" >> ./group
112
+ echo " coder:x:1000:1000::/:/bin/sh" >> ./passwd
113
+
114
+ docker buildx build \
115
+ --platform " $arch " \
116
+ --build-arg " CODER_VERSION=$version " \
117
+ --tag " $image_tag " \
118
+ . 1>&2
106
119
107
120
cdroot
108
121
rm -rf " $temp_dir "
You can’t perform that action at this time.
0 commit comments