Skip to content
Open
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
.gitignore
.dockerignore
out
prebuilt
src
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
21 changes: 12 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
FROM debian:trixie
FROM debian:trixie AS toolchain

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=UTC
ENV IMG_OUT=/artifacts/images
ENV UBOOT_OUT=/artifacts/u-boot
ENV LINUX_OUT=/artifacts/linux

# Add arm64 architecture for cross-compilation
RUN dpkg --add-architecture arm64 && apt-get update
Expand Down Expand Up @@ -64,9 +60,16 @@ RUN pipx install --global git+https://github.com/flipperdevices/bmaptool.git@fli
# Clean up apt cache to reduce image size
RUN apt-get clean && rm -rf /var/lib/apt/lists/* ~/.cargo ~/go

# Clone the flipperone-linux-build-scripts repository
FROM toolchain AS build

ENV IMG_OUT=/artifacts/images
ENV UBOOT_OUT=/artifacts/u-boot
ENV LINUX_OUT=/artifacts/linux

WORKDIR /flipperone-linux-build-scripts
RUN git clone --depth=1 https://github.com/flipperdevices/flipperone-linux-build-scripts .
COPY . .

RUN bash -n docker-entrypoint.sh \
&& install -m 755 docker-entrypoint.sh /usr/local/bin/flipperone-entrypoint

# Entry point
ENTRYPOINT ./build-uboot.sh && ./build-kernel-mainline.sh && ./build-kernel-bsp.sh && ./build-images.sh
ENTRYPOINT ["/usr/local/bin/flipperone-entrypoint"]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,28 @@ docker run --privileged --rm -v "$(pwd)/out:/artifacts" \
flipperone-linux-build-scripts
```

Running the image without a command builds U-Boot, both kernels, and the final images. To open a shell or run an
individual build script, append the command normally:

```bash
docker run --privileged --rm -it -v "$(pwd)/out:/artifacts" \
flipperone-linux-build-scripts bash

docker run --privileged --rm -v "$(pwd)/out:/artifacts" \
flipperone-linux-build-scripts ./build-kernel-mainline.sh
```

The Dockerfile separates the slow-changing compiler and packaging toolchain into a named `toolchain` stage. Build and
tag that stage independently when it should be shared or cached separately from the build scripts:

```bash
docker build --target toolchain -t flipperone-toolchain:trixie .
docker build -t flipperone-linux-build-scripts .
```

CI can push the toolchain target to a registry and provide it as a build cache with `--cache-from`; the final stage
only copies this repository, so ordinary source changes do not reinstall packages or rebuild the Go and Rust tools.

Replace `docker` with `podman` if that's what you have. `--privileged` is required because debos and mmdebstrap use loop devices and mount namespaces.

### Quick start with VS Code Dev Container
Expand Down
12 changes: 12 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

if [ "$#" -gt 0 ]; then
exec "$@"
fi

./build-uboot.sh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small correction on the signal reasoning here: not exec-ing these doesn't orphan the build. Bash is waiting on each script as a foreground process, so a docker stop still tears the child down - it doesn't get abandoned.

Bash won't fire a trap until the current command returns and it won't reap zombies. If we want an instant, clean stop, simplest is docker run --init. Or maybe trap + background + wait.

./build-kernel-mainline.sh
./build-kernel-bsp.sh
exec ./build-images.sh