Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#

#FROM debian:bookworm-slim
FROM ubuntu:22.04
FROM ubuntu:22.04 AS build

#ARG TARGET_ARCH=arm-linux-gnueabihf
ARG TARGET_ARCH=aarch64-linux-gnu
Expand Down Expand Up @@ -37,5 +37,6 @@ RUN ./configure --prefix=/usr --host=${TARGET_ARCH}
RUN make
RUN make binary-dist

#ENTRYPOINT [ "/bin/bash", "-l" ]
CMD [ "/bin/bash", "-l" ]
# Minimal export stage: only copy dist artifacts
FROM scratch AS export
COPY --from=build /opt/dist/ .
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,25 @@ During development, periodically run `autoscan` to detect if changes should be m

## Cross-platform using Docker

There is a `Dockerfile` that can be used to build for armhf and aarch64 on non-linux hosts that support Docker desktop. See `build-all.sh` for an
automated script that generates build artifacts for both.
There is a `Dockerfile` that can be used to build for armhf and aarch64 on non-linux hosts that support Docker Desktop. A `docker-bake.hcl` file plus the
`build-all.sh` helper script will perform parallel multi-architecture builds using Docker Buildx.

```
./build-all.sh

```
Resulting tarballs are copied to `dist/`.

To build only one architecture:
```
docker buildx bake armhf
docker buildx bake arm64
```

Override args example:
```
docker buildx bake armhf --set armhf.args.TARGET_ARCH=arm-linux-gnueabihf
```

# Supported Platforms

Expand Down
19 changes: 6 additions & 13 deletions build-all.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
#!/bin/bash -ueE
#!/usr/bin/env bash
set -ueE

main() {
docker build -t bootcount-builder-armv7 \
--build-arg TARGET_ARCH=arm-linux-gnueabihf .
docker build -t bootcount-builder-armv8 \
--build-arg TARGET_ARCH=aarch64-linux-gnu .

for V in v7 v8; do
TARBALL=$(docker run --rm -it bootcount-builder-arm$V ls -1 dist/ | tr -d '\r' | tr -d '\n')
CONTAINER=$(docker create bootcount-builder-arm$V)
docker cp "$CONTAINER:/opt/dist/$TARBALL" .
docker rm "$CONTAINER"
done
mkdir -p dist
docker buildx bake "$@"
ls -lh dist/
}

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
if [[ ${BASH_SOURCE[0]} == "$0" ]]; then
set -o pipefail
main "$@"
fi
22 changes: 22 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
group "default" {
targets = ["armhf", "arm64"]
}

target "arm64" {
context = "."
dockerfile = "Dockerfile"
tags = ["bootcount-builder:arm64"]
args = {
// this is already the default in the Dockerfile:
// TARGET_ARCH = "aarch64-linux-gnu"
}
output = ["type=local,dest=dist/"]
}

target "armhf" {
inherits = ["arm64"]
args = {
TARGET_ARCH = "arm-linux-gnueabihf"
}
tags = ["bootcount-builder:armhf"]
}