archlinux-docker/Dockerfile.template
Justin Kromlinger d47ca225ee
Replace xz with zstd
Closes #63.

Using `zstd -T0 -8` instead of `gz -T0 -9` results in a larger rootfs
file, but requires significantly less time and memory:

```

zstd  -3 115M   1.60user 0.18system 0:00.32elapsed 557%CPU (0avgtext+0avgdata  130212maxresident)k
zstd  -6 107M   5.03user 0.24system 0:00.72elapsed 729%CPU (0avgtext+0avgdata  149660maxresident)k
zstd  -7 106M   7.33user 0.29system 0:01.04elapsed 728%CPU (0avgtext+0avgdata  174368maxresident)k
zstd  -8 105M   8.45user 0.27system 0:01.23elapsed 707%CPU (0avgtext+0avgdata  173008maxresident)k
zstd  -9 104M   9.35user 0.37system 0:01.42elapsed 683%CPU (0avgtext+0avgdata  335920maxresident)k
zstd -13 104M  30.57user 0.31system 0:04.76elapsed 648%CPU (0avgtext+0avgdata  498740maxresident)k
zstd -19  91M 132.06user 0.53system 0:21.98elapsed 603%CPU (0avgtext+0avgdata 1106328maxresident)k
xz    -9  81M 105.71user 0.58system 0:58.24elapsed 182%CPU (0avgtext+0avgdata 2006964maxresident)k
```

Additionally this drops bash from the build Dockerfile, since `SHELL` is
not OCI compliant.
2022-04-13 17:48:07 +02:00

30 lines
1.2 KiB
Docker

# We're using a multistage Docker build here in order to allow us to release a self-verifying
# Docker image when built on the official Docker infrastructure.
# They require us to verify the source integrity in some way while making sure that this is a
# reproducible build.
# See https://github.com/docker-library/official-images#image-build
# In order to achieve this, we externally host the rootfs archives and their checksums and then
# just download and verify it in the first stage of this Dockerfile.
# The second stage is for actually configuring the system a little bit.
# Some templating is done in order to allow us to easily build different configurations and to
# allow us to automate the releaes process.
FROM alpine:3.12 AS verify
COPY TEMPLATE_ROOTFS_FILE /
RUN apk add --no-cache curl tar zstd
# TEMPLATE_ROOTFS_RELEASE_URL
RUN TEMPLATE_ROOTFS_DOWNLOAD && \
echo "TEMPLATE_ROOTFS_HASH" > /tmp/rootfs.tar.sha256 && \
cat /tmp/rootfs.tar.sha256 && \
sha256sum -c /tmp/rootfs.tar.sha256 && \
mkdir /rootfs && \
tar -C /rootfs --extract --file "${ROOTFS}"
FROM scratch AS root
COPY --from=verify /rootfs/ /
RUN ldconfig
ENV LANG=en_US.UTF-8
CMD ["/usr/bin/bash"]