11# syntax=docker/dockerfile:1.8@sha256:d6d396f3780b1dd56a3acbc975f57bd2fc501989b50164c41387c42d04e780d0
22
33ARG ALPINE_VERSION=3.21
4- ARG ARCH=x86_64
4+ ARG ARCH=${TARGETARCH}
55
66FROM alpine:${ALPINE_VERSION} AS rust-base
77
@@ -18,18 +18,37 @@ ARG RUSTUP_VERSION=1.27.1
1818
1919# Update check: https://github.com/rust-lang/rust/tags
2020ARG RUST_VERSION=1.85.0
21- ARG RUST_ARCH=${ARCH}-unknown-linux-musl
2221
2322# https://github.com/sfackler/rust-openssl/issues/1462
2423ENV RUSTFLAGS="-Ctarget-feature=-crt-static"
2524
26- ADD --chmod=755 https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${RUST_ARCH}/rustup-init /tmp
27- RUN /tmp/rustup-init \
25+ RUN <<EOF
26+ set -eux
27+
28+ apk add --no-cache curl
29+
30+ if [ "$ARCH" = amd64 ]; then
31+ rust_arch=x86_64;
32+ elif [ "$ARCH" = arm64 ]; then
33+ rust_arch=aarch64;
34+ else
35+ echo "Unsupported arch" ;
36+ exit 1
37+ fi
38+
39+ rust_arch=${rust_arch}-unknown-linux-musl
40+
41+ curl -sSL https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${rust_arch}/rustup-init -o /tmp/rustup-init
42+ chmod +x /tmp/rustup-init
43+ /tmp/rustup-init \
2844 -y \
2945 --no-modify-path \
3046 --profile minimal \
3147 --default-toolchain ${RUST_VERSION} \
32- --default-host ${RUST_ARCH}
48+ --default-host ${rust_arch}
49+ rm /tmp/rustup-init
50+ apk del curl
51+ EOF
3352
3453FROM rust-base AS dev-planner
3554
@@ -51,8 +70,8 @@ RUN apk add --no-cache \
5170
5271WORKDIR /usr/src/josh
5372RUN rustup component add rustfmt
54- RUN cargo install --version 0.1.71 cargo-chef
55- RUN cargo install --verbose --version 0.10.0 graphql_client_cli
73+ RUN cargo install --version 0.1.71 cargo-chef &&\
74+ cargo install --verbose --version 0.10.0 graphql_client_cli
5675
5776RUN apk add --no-cache \
5877 bash \
@@ -73,11 +92,13 @@ RUN apk add --no-cache \
7392
7493# Update check: https://github.com/git/git/tags
7594ARG GIT_VERSION=2.45.2
95+ ENV PATH=${PATH}:/opt/git-install/bin
7696WORKDIR /usr/src/git
7797RUN <<EOF
7898set -e
7999wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz
80100tar --extract --gzip --file git-${GIT_VERSION}.tar.gz
101+ rm git-${GIT_VERSION}.tar.gz
81102cd git-${GIT_VERSION}
82103make configure
83104./configure \
@@ -86,13 +107,11 @@ make configure
86107 --exec-prefix=/opt/git-install
87108make -j$(nproc)
88109make install
110+ mkdir /opt/git-install/etc
111+ git config -f /opt/git-install/etc/gitconfig --add safe.directory "*"
112+ git config -f /opt/git-install/etc/gitconfig protocol.file.allow "always"
89113EOF
90114
91- ENV PATH=${PATH}:/opt/git-install/bin
92- RUN mkdir /opt/git-install/etc
93- RUN git config -f /opt/git-install/etc/gitconfig --add safe.directory "*" && \
94- git config -f /opt/git-install/etc/gitconfig protocol.file.allow "always"
95-
96115# Update check: https://github.com/prysk/prysk/releases
97116ARG PRYSK_VERSION=0.20.0
98117
@@ -109,20 +128,23 @@ RUN cd lfs-test-server && GOPATH=/opt/git-lfs go install
109128
110129ENV PATH=${PATH}:/opt/git-lfs/bin
111130
112- RUN git clone https://github.com/git-lfs/git-lfs.git /usr/src/git-lfs
113- WORKDIR /usr/src/git-lfs
114- RUN make
115- RUN cp bin/git-lfs /opt/git-lfs/bin
131+ RUN <<EOF
132+ set -eux
133+ git clone https://github.com/git-lfs/git-lfs.git /usr/src/git-lfs
134+ cd /usr/src/git-lfs
135+ make
136+ cp bin/git-lfs /opt/git-lfs/bin
137+ EOF
116138
117139WORKDIR /usr/src/josh
118140
119141FROM dev AS dev-local
120142
121- RUN mkdir -p /opt/cache && \
122- chmod 777 /opt/cache
123-
124- RUN mkdir -p /josh/static && \
125- chmod 777 /josh/static
143+ RUN <<EOF
144+ set -eux
145+ mkdir -p /opt/cache /josh/static
146+ chmod 777 /opt/cache /josh/static
147+ EOF
126148
127149VOLUME /opt/cache
128150
@@ -136,19 +158,21 @@ RUN npm config set cache /opt/cache/npm-cache --global
136158ARG USER_GID
137159ARG USER_UID
138160
139- RUN \
140- if [ ! $(getent group ${USER_GID}) ] ; then \
141- addgroup \
142- -g ${USER_GID} dev ; \
143- fi
161+ RUN <<EOF
162+ set -eux
163+
164+ if [ ! $(getent group ${USER_GID}) ] ; then
165+ addgroup -g ${USER_GID} dev
166+ fi
144167
145- RUN adduser \
146- -u ${USER_UID} \
147- -G $(getent group ${USER_GID} | cut -d: -f1) \
148- -D \
149- -H \
150- -g '' \
151- dev
168+ adduser \
169+ -u ${USER_UID} \
170+ -G $(getent group ${USER_GID} | cut -d: -f1) \
171+ -D \
172+ -H \
173+ -g '' \
174+ dev
175+ EOF
152176
153177FROM dev AS dev-cache
154178
@@ -201,16 +225,40 @@ COPY --from=build --link=false /opt/cargo-target/release/josh-ssh-shell /usr/bin
201225COPY --from=build --link=false /usr/src/josh/static/ /josh/static/
202226
203227ARG S6_OVERLAY_VERSION=3.1.2.1
204- ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
205- RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
206228ARG ARCH
207- ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${ARCH}.tar.xz /tmp
208- RUN tar -C / -Jxpf /tmp/s6-overlay-${ARCH}.tar.xz
229+ RUN <<EOF
230+ set -eux
231+
232+ apk add --no-cache curl
233+
234+ curl -sSL https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz \
235+ -o /tmp/s6-overlay-noarch.tar.xz
236+ tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
237+ rm /tmp/s6-overlay-noarch.tar.xz
238+
239+ if [ "$ARCH" = amd64 ]; then
240+ s6_arch=x86_64;
241+ elif [ "$ARCH" = arm64 ]; then
242+ s6_arch=aarch64;
243+ else
244+ echo "Unsupported arch" ;
245+ exit 1
246+ fi
247+
248+ curl -sSL https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${s6_arch}.tar.xz \
249+ -o /tmp/s6-overlay-arch.tar.xz
250+ tar -C / -Jxpf /tmp/s6-overlay-arch.tar.xz
251+ rm /tmp/s6-overlay-arch.tar.xz
252+
253+ apk del curl
254+ EOF
209255
210256ARG GIT_GID_UID=2001
211257
212- RUN addgroup -g ${GIT_GID_UID} git
213- RUN adduser \
258+ RUN <<EOF
259+ set -eux
260+ addgroup -g ${GIT_GID_UID} git
261+ adduser \
214262 -h /home/git \
215263 -s /usr/bin/josh-ssh-shell \
216264 -G git \
@@ -219,7 +267,8 @@ RUN adduser \
219267 git
220268
221269# https://unix.stackexchange.com/a/193131/336647
222- RUN usermod -p '*' git
270+ usermod -p '*' git
271+ EOF
223272
224273COPY --from=docker --link=false etc/ssh/sshd_config.template /etc/ssh/sshd_config.template
225274
0 commit comments