|
| 1 | +# syntax=docker/dockerfile:1.4 |
| 2 | +# |
1 | 3 | # This Dockerfile creates a container that will create an EFI executable and
|
2 | 4 | # separate kernel/initramfs components from a ZFSBootMenu repository. The
|
3 | 5 | # container will pre-populate its /zbm directory with a clone of the master
|
4 | 6 | # branch of the upstream ZFSBootMenu branch and build the images from that.
|
5 | 7 | #
|
6 | 8 | # To use a different ZFSBootMenu repository or version, bind-mound the
|
7 | 9 | # repository you want on /zbm inside the container.
|
| 10 | +# |
| 11 | +# Note - this Dockerfile depends on Docker >= 23 and the docker buildx plugin. |
8 | 12 |
|
9 | 13 | # Use the official Void Linux container
|
10 |
| -FROM ghcr.io/void-linux/void-glibc-full:latest |
11 |
| -ARG ZBM_COMMIT_HASH |
| 14 | +FROM ghcr.io/void-linux/void-glibc-full |
| 15 | +LABEL org.opencontainers.image.authors="ZFSBootMenu Team, https://zfsbootmenu.org" |
| 16 | + |
| 17 | +ARG XBPS_REPOS="https://repo-fastly.voidlinux.org/current" |
| 18 | + |
| 19 | +# Include the specified Void Linux kernel series in the image; kernel |
| 20 | +# series take the form linux<major>.<minor> |
| 21 | +# |
| 22 | +# Default: linux5.10 linux5.15 linux6.1 |
| 23 | +# (multiple entries must be seperated by spaces) |
| 24 | +ARG KERNELS="linux5.10 linux5.15 linux6.1" |
| 25 | +# Update repos and install kernels and base dependencies. |
12 | 26 |
|
13 |
| -# Ensure everything is up-to-date |
14 |
| -RUN xbps-install -Suy xbps && xbps-install -uy |
| 27 | +# Run the following within an external cache (/var/cache/xbps) for the |
| 28 | +# package manager; so when this layer is rebuilt, at least you save |
| 29 | +# some bandwidth. |
| 30 | +RUN --mount=type=cache,target=/var/cache/xbps <<-EOF |
| 31 | + if [ -z "${KERNELS}" ]; then |
| 32 | + echo "ARG KERNELS must contain a value" |
| 33 | + exit 1 |
| 34 | + fi |
15 | 35 |
|
16 |
| -# Prefer an LTS version over whatever Void thinks is current |
17 |
| -RUN echo "ignorepkg=linux" > /etc/xbps.d/10-nolinux.conf \ |
18 |
| - && echo "ignorepkg=linux-headers" >> /etc/xbps.d/10-nolinux.conf |
| 36 | + mkdir -p /etc/xbps.d |
| 37 | + for _repo in ${XBPS_REPOS}; do |
| 38 | + echo "repository=${_repo}" >> /etc/xbps.d/00-custom-repos.conf |
| 39 | + done |
19 | 40 |
|
20 |
| -# Install components necessary to build the image |
21 |
| -RUN xbps-query -Rp run_depends zfsbootmenu | xargs xbps-install -y |
22 |
| -RUN xbps-install -y linux5.10 linux5.10-headers \ |
23 |
| - zfs gummiboot-efistub curl yq-go bash kbd \ |
24 |
| - terminus-font dracut mkinitcpio cryptsetup |
| 41 | + # Ensure everything is up-to-date |
| 42 | + xbps-install -Suy xbps && xbps-install -Suy |
25 | 43 |
|
26 |
| -# Remove headers and massive dkms development toolchain; binutils |
27 |
| -# provides objcopy, which is necessary for UEFI bundle creation |
28 |
| -RUN xbps-pkgdb -m manual binutils |
29 |
| -RUN echo "ignorepkg=dkms" > /etc/xbps.d/10-nodkms.conf |
30 |
| -RUN xbps-remove -Roy linux5.10-headers dkms && rm -f /var/cache/xbps/* |
| 44 | + # Prefer an LTS version over whatever Void thinks is current |
| 45 | + echo "ignorepkg=linux" > /etc/xbps.d/10-nolinux.conf |
| 46 | + echo "ignorepkg=linux-headers" >> /etc/xbps.d/10-nolinux.conf |
31 | 47 |
|
| 48 | + # Prevent initramfs kernel hooks from being installed |
| 49 | + echo "noextract=/usr/libexec/mkinitcpio/*" > /etc/xbps.d/15-noinitramfs.conf |
| 50 | + echo "noextract=/usr/libexec/dracut/*" >> /etc/xbps.d/15-noinitramfs.conf |
| 51 | + |
| 52 | + for _kern in ${KERNELS}; do |
| 53 | + kern_headers="${kern_headers} ${_kern}-headers" |
| 54 | + done |
| 55 | + |
| 56 | + # Install ZFSBootMenu dependencies and components necessary to build images |
| 57 | + zbm_deps="$(xbps-query -Rp run_depends zfsbootmenu)" |
| 58 | + xbps-install -y ${KERNELS} ${kern_headers} ${zbm_deps} \ |
| 59 | + zstd gummiboot-efistub curl yq-go bash kbd \ |
| 60 | + dracut mkinitcpio dracut-network gptfdisk iproute2 iputils parted \ |
| 61 | + dosfstools e2fsprogs efibootmgr cryptsetup openssh util-linux kpartx |
| 62 | + |
| 63 | + # Remove headers and development toolchain, but keep binutils for objcopy |
| 64 | + echo "ignorepkg=dkms" > /etc/xbps.d/10-nodkms.conf |
| 65 | + xbps-pkgdb -m manual binutils |
| 66 | + xbps-remove -Roy dkms ${kern_headers} |
| 67 | + EOF |
| 68 | + |
| 69 | +# ZFSBootMenu commit hash, tag or branch name used by |
| 70 | +# default to build ZFSBootMenu images (default: master) |
| 71 | +ARG ZBM_COMMIT_HASH= |
32 | 72 | # Record a commit hash if one was provided
|
33 |
| -RUN if [ -n "${ZBM_COMMIT_HASH}" ]; then echo "${ZBM_COMMIT_HASH}" > /etc/zbm-commit-hash; fi |
| 73 | +RUN [ -z "${ZBM_COMMIT_HASH}" ] || echo "${ZBM_COMMIT_HASH}" > /etc/zbm-commit-hash |
| 74 | + |
| 75 | +# Include the specified Void Linux package in the image |
| 76 | +# (multiple entries must be seperated by spaces) |
| 77 | +ARG PACKAGES= |
| 78 | +# Run ${PACKAGES} install in seperate layer so that the zfs dkms packages |
| 79 | +# are not rebuilt when ${PACKAGES} change. reuse. Additionally: use xbps cache. |
| 80 | +# Install ZFSBootMenu dependencies and components necessary to build images |
| 81 | +RUN --mount=type=cache,target=/var/cache/xbps \ |
| 82 | + [ -z "${PACKAGES}" ] || xbps-install -y ${PACKAGES} |
34 | 83 |
|
35 |
| -# Copy the build script |
36 |
| -COPY build-init.sh /build-init.sh |
| 84 | +# Free space in image |
| 85 | +RUN rm -f /var/cache/xbps/* |
37 | 86 |
|
| 87 | +ARG ZBM_BUILDER=build-init.sh |
| 88 | +COPY --chmod=755 ${ZBM_BUILDER} / |
38 | 89 | # Run the build script with no arguments by default
|
39 |
| -ENTRYPOINT [ "/build-init.sh" ] |
40 |
| -CMD [ ] |
| 90 | +ENTRYPOINT [ "/${ZBM_BUILDER}" ] |
0 commit comments