Skip to content

Commit d16c316

Browse files
authored
Merge pull request #14 from Yolean/scratch-with-cp
Add scratch+cp image called "blobs"
2 parents cf3787f + 44611db commit d16c316

File tree

3 files changed

+122
-4
lines changed

3 files changed

+122
-4
lines changed

blobs/Dockerfile

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
FROM --platform=$TARGETPLATFORM alpine:3.19@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b
2+
3+
RUN set -eux; \
4+
apk add --no-cache \
5+
bzip2 \
6+
coreutils \
7+
curl \
8+
gcc \
9+
gnupg \
10+
linux-headers \
11+
make \
12+
musl-dev \
13+
patch \
14+
tzdata \
15+
# busybox's tar ironically does not maintain mtime of directories correctly (which we need for SOURCE_DATE_EPOCH / reproducibility)
16+
tar \
17+
;
18+
19+
# pub 1024D/ACC9965B 2006-12-12
20+
# Key fingerprint = C9E9 416F 76E6 10DB D09D 040F 47B7 0C55 ACC9 965B
21+
# uid Denis Vlasenko <[email protected]>
22+
# sub 1024g/2C766641 2006-12-12
23+
RUN mkdir -p ~/.gnupg && gpg --batch --keyserver keyserver.ubuntu.com --recv-keys C9E9416F76E610DBD09D040F47B70C55ACC9965B
24+
25+
# https://busybox.net: 19 May 2023
26+
ENV BUSYBOX_VERSION 1.36.1
27+
ENV BUSYBOX_SHA256 b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314
28+
29+
RUN set -eux; \
30+
tarball="busybox-${BUSYBOX_VERSION}.tar.bz2"; \
31+
curl -fL -o busybox.tar.bz2.sig "https://busybox.net/downloads/$tarball.sig"; \
32+
curl -fL -o busybox.tar.bz2 "https://busybox.net/downloads/$tarball"; \
33+
echo "$BUSYBOX_SHA256 *busybox.tar.bz2" | sha256sum -c -; \
34+
gpg --batch --verify busybox.tar.bz2.sig busybox.tar.bz2; \
35+
# Alpine... 😅
36+
mkdir -p /usr/src; \
37+
tar -xf busybox.tar.bz2 -C /usr/src "busybox-$BUSYBOX_VERSION"; \
38+
mv "/usr/src/busybox-$BUSYBOX_VERSION" /usr/src/busybox; \
39+
rm busybox.tar.bz2*; \
40+
\
41+
# save the tarball's filesystem timestamp persistently (in case building busybox modifies it) so we can use it for reproducible rootfs later
42+
SOURCE_DATE_EPOCH="$(stat -c '%Y' /usr/src/busybox | tee /usr/src/busybox.SOURCE_DATE_EPOCH)"; \
43+
date="$(date -d "@$SOURCE_DATE_EPOCH" '+%Y%m%d%H%M.%S')"; \
44+
touch -t "$date" /usr/src/busybox.SOURCE_DATE_EPOCH; \
45+
# for logging validation/edification
46+
date --date "@$SOURCE_DATE_EPOCH" --rfc-2822
47+
48+
WORKDIR /usr/src/busybox
49+
50+
RUN set -eux; \
51+
\
52+
# build date/time gets embedded in the BusyBox binary -- SOURCE_DATE_EPOCH should override that
53+
SOURCE_DATE_EPOCH="$(cat /usr/src/busybox.SOURCE_DATE_EPOCH)"; \
54+
export SOURCE_DATE_EPOCH; \
55+
# (has to be set in the config stage for making sure "AUTOCONF_TIMESTAMP" is embedded correctly)
56+
\
57+
setConfs=' \
58+
CONFIG_LS=y \
59+
CONFIG_CP=y \
60+
CONFIG_AR=y \
61+
CONFIG_FEATURE_AR_CREATE=y \
62+
CONFIG_FEATURE_AR_LONG_FILENAMES=y \
63+
# CONFIG_LAST_SUPPORTED_WCHAR: see https://github.com/docker-library/busybox/issues/13 (UTF-8 input)
64+
CONFIG_LAST_SUPPORTED_WCHAR=0 \
65+
CONFIG_STATIC=y \
66+
'; \
67+
\
68+
unsetConfs=' \
69+
CONFIG_FEATURE_SYNC_FANCY \
70+
\
71+
# see https://wiki.musl-libc.org/wiki/Building_Busybox
72+
CONFIG_FEATURE_HAVE_RPC \
73+
CONFIG_FEATURE_INETD_RPC \
74+
CONFIG_FEATURE_UTMP \
75+
CONFIG_FEATURE_WTMP \
76+
'; \
77+
\
78+
make allnoconfig; \
79+
\
80+
for conf in $unsetConfs; do \
81+
sed -i \
82+
-e "s!^$conf=.*\$!# $conf is not set!" \
83+
.config; \
84+
done; \
85+
\
86+
for confV in $setConfs; do \
87+
conf="${confV%=*}"; \
88+
sed -i \
89+
-e "s!^$conf=.*\$!$confV!" \
90+
-e "s!^# $conf is not set\$!$confV!" \
91+
.config; \
92+
if ! grep -q "^$confV\$" .config; then \
93+
echo "$confV" >> .config; \
94+
fi; \
95+
done;
96+
97+
RUN set -eux; \
98+
nproc="$(nproc)"; \
99+
make -j "$nproc" busybox;
100+
101+
FROM --platform=$TARGETPLATFORM alpine:3.19@sha256:c5b1261d6d3e43071626931fc004f70149baeba2c8ec672bd4f27761f8e1ad6b as bin
102+
103+
WORKDIR /target
104+
105+
COPY --from=0 /usr/src/busybox/busybox ./busybox
106+
107+
RUN set -eux; \
108+
ln -s ./busybox ./cp; \
109+
ln -s ./busybox ./ls; \
110+
ls -lh .
111+
112+
FROM --platform=$TARGETPLATFORM scratch
113+
114+
USER 65532:65534
115+
116+
COPY --from=bin /target /bin
117+
118+
WORKDIR /blobs
119+
ENTRYPOINT [ "/bin/cp" ]
120+
# our binary has no help section
121+
CMD [ "requires-cp-args", "/tmp/to/somewhere" ]

hooks/build

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ git-init
2626
toil
2727
toil-network
2828
node-distroless
29+
blobs
2930
"
3031

3132
MULTIARCH_TONONROOT="
@@ -42,7 +43,6 @@ toil-storage
4243
"
4344

4445
AMD64ONLY="
45-
scratch
4646
runtime-quarkus
4747
runtime-quarkus-deno
4848
runtime-deno

scratch/Dockerfile

-3
This file was deleted.

0 commit comments

Comments
 (0)