Skip to content

Commit fc6eeb6

Browse files
committed
deterministic docker support
1 parent 4ebd0b6 commit fc6eeb6

3 files changed

Lines changed: 33 additions & 13 deletions

File tree

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!target

Dockerfile

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
FROM local/stage0 as stage0
2-
3-
FROM debian as fetch
4-
RUN apt update && apt install -y curl gcc
5-
ADD . live-bootstrap
6-
WORKDIR live-bootstrap
7-
RUN ./download-distfiles.sh
8-
RUN mv target/ /rootfs/
9-
101
FROM scratch as build
11-
COPY --from=fetch /rootfs .
12-
ENV PATH=/bin
2+
ADD target/ /
133
RUN ["/bootstrap-seeds/POSIX/x86/kaem-optional-seed"]
4+
5+
FROM build as install
6+
ENV PATH=/bin:/usr/sbin:/usr/bin
7+
RUN set -eux; \
8+
rm -rf /usr/lib/python*/__pycache__; \
9+
mkdir -p /rootfs/etc /rootfs/home/user; \
10+
cp -R $(ls -d /etc/* | grep -v '\(resolv.conf\|hosts\)') /rootfs/etc/; \
11+
cp -R lib usr bin var /rootfs/; \
12+
echo "user:x:1000:" > /rootfs/etc/group; \
13+
echo "user:x:1000:1000::/home/user:/bin/bash" > /rootfs/etc/passwd; \
14+
find /rootfs -exec touch -hcd "@0" "{}" +
15+
16+
FROM scratch as package
17+
COPY --from=install /rootfs /
18+
USER 1000:1000
19+
ENTRYPOINT ["/bin/bash"]
20+
ENV TZ=UTC
21+
ENV LANG=C.UTF-8
22+
ENV SOURCE_DATE_EPOCH=1
23+
ENV KCONFIG_NOTIMESTAMP=1
24+
ENV PS1="bootstrap$ "

rootfs.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def check_types():
157157
else:
158158
args.target_size = 0
159159

160+
if args.docker:
161+
args.external_sources = True
162+
160163
# Swap file size validation
161164
if args.qemu or args.bare_metal:
162165
args.swap = (int(str(args.swap).rstrip('gGmM')) *
@@ -209,9 +212,13 @@ def bootstrap(args, generator, target, size):
209212
arch = stage0_arch_map.get(args.arch, args.arch)
210213
init = os.path.join(os.sep, 'bootstrap-seeds', 'POSIX', arch, 'kaem-optional-seed')
211214
print(generator.target_dir, init)
212-
run('env', '-i', 'DOCKER_BUILDKIT=1', 'docker', 'build',
215+
run('env', '-i', 'DOCKER_BUILDKIT=1', 'SOURCE_DATE_EPOCH=1',
216+
'docker', 'build',
217+
'--build-arg=SOURCE_DATE_EPOCH=1',
213218
'--progress=plain',
214-
'-t', 'local/live',
219+
'--platform=linux/amd64',
220+
'--target=package',
221+
'-t', 'local/live-bootstrap',
215222
'.')
216223

217224
elif args.bwrap:

0 commit comments

Comments
 (0)