-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile.base
More file actions
148 lines (134 loc) · 4.67 KB
/
Copy pathContainerfile.base
File metadata and controls
148 lines (134 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
FROM docker.io/archlinux/archlinux:latest AS bootc-builder
ARG BOOTC_VERSION=v1.16.6
# Arch does not yet package bootc. Build one pinned upstream release in an
# isolated stage so no compiler, source tree, or build-only account reaches
# the operating-system image.
RUN sed -i '/^[[:space:]]*DownloadUser[[:space:]]/d' /etc/pacman.conf
RUN --mount=type=cache,dst=/root/.cargo/registry \
--mount=type=cache,dst=/root/.cargo/git \
pacman -Syu --needed --noconfirm \
git \
glib2 \
go-md2man \
make \
ostree \
pkgconf \
rust
WORKDIR /tmp/bootc
RUN git clone --branch "${BOOTC_VERSION}" --depth 1 \
https://github.com/bootc-dev/bootc.git . && \
make bin install-all DESTDIR=/output
# install-all also emits bootc's development integration-test executable and
# keeps full Rust debug sections. Neither belongs in the deployed OS image.
RUN rm -f /output/usr/bin/bootc-integration-tests && \
strip --strip-unneeded \
/output/usr/bin/bootc \
/output/usr/bin/system-reinstall-bootc
FROM docker.io/archlinux/archlinux:latest AS system
COPY --from=bootc-builder /output /
# Keep pacman's mutable database and cache outside the image-managed /usr
# deployment. This follows bootcrew/mono's Arch base design and keeps pacman
# usable inside an explicit `bootc usr-overlay`.
RUN grep "= */var" /etc/pacman.conf | \
sed "/= *\/var/s/.*=// ; s/ //" | \
xargs -n1 sh -c \
'mkdir -p "/usr/lib/sysimage/$(dirname "$(printf %s "$1" | sed "s@/var/@@")")"; mv -v "$1" "/usr/lib/sysimage/$(printf %s "$1" | sed "s@/var/@@")"' '' && \
sed -i \
-e "/= *\/var/ s/^#//" \
-e "s@= */var@= /usr/lib/sysimage@g" \
-e "/DownloadUser/d" \
/etc/pacman.conf
RUN --mount=type=tmpfs,dst=/tmp \
--mount=type=cache,dst=/usr/lib/sysimage/cache/pacman \
pacman -Syu --needed --noconfirm \
base \
base-devel \
btrfs-progs \
bubblewrap \
networkmanager \
cargo \
go-md2man \
gcc-libs \
glib2 \
glibc \
openssl \
ostree \
zlib \
zstd \
cargo \
cpio \
cryptsetup \
dbus \
dosfstools \
dracut \
e2fsprogs \
glib2 \
linux \
ostree \
shadow \
skopeo \
podman \
buildah \
systemd \
tpm2-tools \
tpm2-tss && \
pacman -Scc --noconfirm
RUN chmod 4755 /usr/bin/newuidmap && \
chmod 4755 /usr/bin/newgidmap
RUN install -d /usr/lib/dracut/dracut.conf.d && \
printf '%s\n' \
'systemdsystemconfdir=/etc/systemd/system' \
'systemdsystemunitdir=/usr/lib/systemd/system' \
> /usr/lib/dracut/dracut.conf.d/30-archlinux-bootc-module.conf && \
printf '%s\n' \
'reproducible=yes' \
'hostonly=no' \
'compress=zstd' \
'add_dracutmodules+=" ostree bootc crypt dm btrfs tpm2-tss "' \
> /usr/lib/dracut/dracut.conf.d/30-archlinux-bootc-container-build.conf && \
kernel_dir="$(find /usr/lib/modules -mindepth 1 -maxdepth 1 -type d | sort -V | tail -1)" && \
test -n "$kernel_dir" && \
dracut --force "${kernel_dir}/initramfs.img"
RUN sed -i 's|^HOME=.*|HOME=/var/home|' /etc/default/useradd && \
printf 'uninitialized\n' > /etc/machine-id && \
systemctl mask systemd-firstboot.service && \
rm -rf \
/boot \
/home \
/root \
/tmp \
/usr/local \
/srv \
/opt \
/mnt \
/var \
/usr/lib/sysimage/log \
/usr/lib/sysimage/cache/pacman/pkg && \
find /run -mindepth 1 -maxdepth 1 ! -name .containerenv -exec rm -rf -- {} + && \
install -d /sysroot /boot /run /usr/lib/ostree /var && \
install -d -m 1777 /tmp && \
ln -sT sysroot/ostree /ostree && \
ln -sT var/roothome /root && \
ln -sT var/srv /srv && \
ln -sT var/opt /opt && \
ln -sT var/mnt /mnt && \
ln -sT var/home /home && \
ln -sT ../var/usrlocal /usr/local && \
printf '%s\n' \
'd /var/opt 0755 root root -' \
'd /var/home 0755 root root -' \
'd /var/srv 0755 root root -' \
'd /var/mnt 0755 root root -' \
'd /var/usrlocal 0755 root root -' \
'd /var/roothome 0700 root root -' \
'd /run/media 0755 root root -' \
> /usr/lib/tmpfiles.d/bootc-base-dirs.conf && \
printf '%s\n' \
'[composefs]' \
'enabled = yes' \
'[sysroot]' \
'readonly = true' \
> /usr/lib/ostree/prepare-root.conf
LABEL containers.bootc=1
LABEL org.opencontainers.image.source="https://github.com/oci-native/archlinux"
RUN bootc container lint --fatal-warnings