Skip to content

Commit 0d7dd2c

Browse files
authored
Merge pull request #936 from cgwalters/add-container
Update Dockerfile to use bootc
2 parents 7811740 + 294a5ec commit 0d7dd2c

File tree

6 files changed

+41
-61
lines changed

6 files changed

+41
-61
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ jobs:
2828
runs-on: [ "${{ matrix.runner }}" ]
2929

3030
steps:
31+
- name: Get a newer podman for heredoc support (from debian testing)
32+
run: |
33+
set -eux
34+
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
35+
sudo apt update
36+
sudo apt install -y crun/testing podman/testing skopeo/testing
37+
3138
- uses: actions/checkout@v4
3239

3340
- name: Install podman
@@ -37,7 +44,7 @@ jobs:
3744
sudo apt install -y podman
3845
3946
- name: build
40-
run: sudo podman build -t localhost/bootupd:latest -f ci/Containerfile.c9s .
47+
run: sudo podman build -t localhost/bootupd:latest -f Dockerfile .
4148

4249
- name: bootupctl status in container
4350
run: |
@@ -60,7 +67,7 @@ jobs:
6067
run: |
6168
set -xeuo pipefail
6269
sudo truncate -s 10G myimage.raw
63-
sudo podman run --rm -ti --privileged -v .:/target --pid=host --security-opt label=disable \
70+
sudo podman run --rm --privileged -v .:/target --pid=host --security-opt label=disable \
6471
-v /var/lib/containers:/var/lib/containers \
6572
-v /dev:/dev \
6673
localhost/bootupd:latest bootc install to-disk --skip-fetch-check \
@@ -88,6 +95,7 @@ jobs:
8895
sudo podman run --rm -ti --privileged -v /:/target --pid=host --security-opt label=disable \
8996
-v /dev:/dev -v /var/lib/containers:/var/lib/containers \
9097
localhost/bootupd:latest bootc install to-filesystem --skip-fetch-check \
98+
--acknowledge-destructive \
9199
--disable-selinux --replace=alongside /target
92100
# Verify we injected static configs
93101
jq -re '.["static-configs"].version' /boot/bootupd-state.json

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Build from the current git into a c9s-bootc container image.
2+
# Use e.g. --build-arg=base=quay.io/fedora/fedora-bootc:41 to target
3+
# Fedora or another base image instead.
4+
#
5+
ARG base=quay.io/centos-bootc/centos-bootc:stream9
6+
7+
FROM $base as build
8+
# This installs our package dependencies, and we want to cache it independently of the rest.
9+
# Basically we don't want changing a .rs file to blow out the cache of packages.
10+
RUN <<EORUN
11+
set -xeuo pipefail
12+
dnf -y install cargo git openssl-devel
13+
EORUN
14+
# Now copy the source
15+
COPY . /build
16+
WORKDIR /build
17+
# See https://www.reddit.com/r/rust/comments/126xeyx/exploring_the_problem_of_faster_cargo_docker/
18+
# We aren't using the full recommendations there, just the simple bits.
19+
RUN --mount=type=cache,target=/build/target --mount=type=cache,target=/var/roothome \
20+
make && make install-all DESTDIR=/out
21+
22+
FROM $base
23+
# Clean out the default to ensure we're using our updated content
24+
RUN rpm -e bootupd
25+
COPY --from=build /out/ /
26+
# Sanity check this too
27+
RUN bootc container lint --fatal-warnings
28+

Dockerfile.build

Lines changed: 0 additions & 9 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ all:
2323
cargo build ${CARGO_ARGS}
2424
ln -f target/${PROFILE}/bootupd target/${PROFILE}/bootupctl
2525

26-
.PHONY: create-build-container
27-
create-build-container:
28-
${CONTAINER_RUNTIME} build -t ${IMAGE_NAME} -f Dockerfile.build
29-
30-
.PHONY: build-in-container
31-
build-in-container: create-build-container
32-
${CONTAINER_RUNTIME} run -ti --rm -v .:/srv/bootupd:z ${IMAGE_PREFIX}${IMAGE_NAME} make
33-
3426
.PHONY: install
3527
install:
3628
mkdir -p "${DESTDIR}$(PREFIX)/bin" "${DESTDIR}$(LIBEXECDIR)"
@@ -46,8 +38,5 @@ install-grub-static:
4638
install-systemd-unit:
4739
install -m 644 -D -t "${DESTDIR}$(PREFIX)/lib/systemd/system/" systemd/bootloader-update.service
4840

49-
.PHONY: bin-archive
50-
bin-archive:
51-
rm target/inst -rf
52-
$(MAKE) install install-grub-static DESTDIR=$$(pwd)/target/inst
53-
tar -C target/inst -c --zstd -f target/bootupd.tar.zst .
41+
.PHONY: install-all
42+
install-all: install install-grub-static install-systemd-unit

README-devel.md

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,7 @@ See also [the coreos-assembler docs](https://coreos.github.io/coreos-assembler/w
1717

1818
## Building With Containers
1919

20-
Many folks use a pet container or toolbox to do development on immutable, partially mutabable, or non-Linux OS's. For those who don't use a pet/toolbox and you'd prefer not to modify your host system for development you can use the `build-in-container` make target to execute building inside a container.
21-
22-
```
23-
$ make build-in-container
24-
podman build -t bootupd-build -f Dockerfile.build
25-
STEP 1: FROM registry.fedoraproject.org/fedora:latest
26-
STEP 2: VOLUME /srv/bootupd
27-
--> Using cache a033bf0e43d560e72d7187459d7fad65ab30a1d01c576e8257194d82836472f7
28-
STEP 3: WORKDIR /srv/bootupd
29-
--> Using cache 756114416fb4a68e72b68a2097c57d9cb94c830f5b351401319baeafa062695e
30-
STEP 4: RUN dnf update -y && dnf install -y make cargo rust glib2-devel openssl-devel ostree-devel
31-
--> Using cache a8e2b525ff0701f735e01bb5703c63bb0e67683625093d34be34bf1123a7f954
32-
STEP 5: COMMIT bootupd-build
33-
--> a8e2b525ff0
34-
a8e2b525ff0701f735e01bb5703c63bb0e67683625093d34be34bf1123a7f954
35-
podman run -ti --rm -v .:/srv/bootupd:z localhost/bootupd-build make
36-
cargo build --release
37-
Updating git repository `https://gitlab.com/cgwalters/ostree-rs`
38-
Updating crates.io index
39-
[...]
40-
$ ls target/release/bootupd
41-
target/release/bootupd
42-
$
43-
```
20+
There's a reference [Dockerfile](Dockerfile) that builds on [CentOS Stream bootc](https://docs.fedoraproject.org/en-US/bootc/).
4421

4522
## Integrating bootupd into a distribution/OS
4623

ci/Containerfile.c9s

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)