Skip to content

Commit 831d55a

Browse files
midzelisahesford
authored andcommitted
releng/docker: Dockerfile parity with image-build.sh
Closes: #478 [via git-merge-pr]
1 parent f09176d commit 831d55a

File tree

1 file changed

+72
-22
lines changed

1 file changed

+72
-22
lines changed

releng/docker/Dockerfile

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,90 @@
1+
# syntax=docker/dockerfile:1.4
2+
#
13
# This Dockerfile creates a container that will create an EFI executable and
24
# separate kernel/initramfs components from a ZFSBootMenu repository. The
35
# container will pre-populate its /zbm directory with a clone of the master
46
# branch of the upstream ZFSBootMenu branch and build the images from that.
57
#
68
# To use a different ZFSBootMenu repository or version, bind-mound the
79
# repository you want on /zbm inside the container.
10+
#
11+
# Note - this Dockerfile depends on Docker >= 23 and the docker buildx plugin.
812

913
# 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.
1226

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
1535

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
1940

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
2543

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
3147

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=
3272
# 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}
3483

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/*
3786

87+
ARG ZBM_BUILDER=build-init.sh
88+
COPY --chmod=755 ${ZBM_BUILDER} /
3889
# Run the build script with no arguments by default
39-
ENTRYPOINT [ "/build-init.sh" ]
40-
CMD [ ]
90+
ENTRYPOINT [ "/${ZBM_BUILDER}" ]

0 commit comments

Comments
 (0)