Skip to content

Commit b624020

Browse files
committed
Update Dockerfile to use bootc
- This is just way easier to understand and use - Unifies with the prior distinct ci/ version - This also specifically inherits the bits we have in bootc to set up rust to cache to a volume so incremental builds work Signed-off-by: Colin Walters <[email protected]>
1 parent 1234a1b commit b624020

File tree

6 files changed

+33
-55
lines changed

6 files changed

+33
-55
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
sudo apt install -y podman
4545
4646
- name: build
47-
run: sudo podman build -t localhost/bootupd:latest -f ci/Containerfile.c9s .
47+
run: sudo podman build -t localhost/bootupd:latest -f Dockerfile .
4848

4949
- name: bootupctl status in container
5050
run: |

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: 3 additions & 8 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,6 +38,9 @@ install-grub-static:
4638
install-systemd-unit:
4739
install -m 644 -D -t "${DESTDIR}$(PREFIX)/lib/systemd/system/" systemd/bootloader-update.service
4840

41+
.PHONY: install-all
42+
install-all: install install-grub-static install-systemd-unit
43+
4944
.PHONY: bin-archive
5045
bin-archive:
5146
rm target/inst -rf

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)