diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index a585a19..ca5e4b3 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -22,35 +22,14 @@ jobs: needs: format runs-on: ubuntu-latest container: - image: jaypoch/lumabuilder:latest + image: jaypoch/luma-markdown-builder:latest + env: + PATH: /root/.cargo/bin:/usr/local/bin:/usr/bin:/bin steps: - name: Checkout code uses: actions/checkout@v4 - - name: Install native packaging tools - run: | - set -eu - export PATH="$HOME/.cargo/bin:$PATH" - - if ! command -v rustup >/dev/null 2>&1; then - curl --fail --silent --show-error https://sh.rustup.rs \ - | sh -s -- -y --profile minimal - fi - export PATH="$HOME/.cargo/bin:$PATH" - rustup default stable - - if ! command -v zig >/dev/null 2>&1; then - curl --fail --silent --show-error --location \ - https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz \ - --output /tmp/zig.tar.xz - tar -xJf /tmp/zig.tar.xz -C /tmp - ln -s /tmp/zig-x86_64-linux-0.16.0/zig "$HOME/.cargo/bin/zig" - fi - - cargo install --locked queso - cargo install cargo-zigbuild - - name: Build x86_64 and ARM64 binaries run: ./scripts/build-linux-binaries.sh diff --git a/Dockerfile.luma-builder b/Dockerfile.luma-builder new file mode 100644 index 0000000..7a5c399 --- /dev/null +++ b/Dockerfile.luma-builder @@ -0,0 +1,71 @@ +FROM alpine:3.20 + +ARG TARGETARCH + +RUN apk add --no-cache \ + bash \ + build-base \ + ca-certificates \ + curl \ + erlang \ + erlang-dev \ + git \ + nodejs \ + npm \ + openssl-dev \ + pkgconf \ + tar \ + xz + +# Install the Gleam compiler matching the architecture of this image. +RUN set -eux; \ + case "$TARGETARCH" in \ + amd64) GLEAM_ARCH="x86_64-unknown-linux-musl" ;; \ + arm64) GLEAM_ARCH="aarch64-unknown-linux-musl" ;; \ + *) echo "Unsupported architecture: $TARGETARCH" >&2; exit 1 ;; \ + esac; \ + curl --fail --silent --show-error --location \ + "https://github.com/gleam-lang/gleam/releases/download/v1.18.1/gleam-v1.18.1-${GLEAM_ARCH}.tar.gz" \ + --output /tmp/gleam.tar.gz; \ + tar -xzf /tmp/gleam.tar.gz -C /tmp; \ + install -m 0755 /tmp/gleam /usr/local/bin/gleam; \ + rm -rf /tmp/gleam /tmp/gleam.tar.gz + +ENV PATH="/root/.cargo/bin:/usr/local/bin:${PATH}" + +# Rust is used by Queso to compile its self-contained launcher. +RUN curl --fail --silent --show-error https://sh.rustup.rs \ + | sh -s -- -y --profile minimal \ + && rustup default stable \ + && rustup target add \ + x86_64-unknown-linux-musl \ + aarch64-unknown-linux-musl + +# Zig is used for the native cross-compilation and is installed for the +# architecture running the builder. +RUN set -eux; \ + case "$TARGETARCH" in \ + amd64) ZIG_ARCH="x86_64" ;; \ + arm64) ZIG_ARCH="aarch64" ;; \ + *) echo "Unsupported architecture: $TARGETARCH" >&2; exit 1 ;; \ + esac; \ + curl --fail --silent --show-error --location \ + "https://ziglang.org/download/0.16.0/zig-${ZIG_ARCH}-linux-0.16.0.tar.xz" \ + --output /tmp/zig.tar.xz; \ + mkdir -p /opt/zig; \ + tar -xJf /tmp/zig.tar.xz --strip-components=1 -C /opt/zig; \ + ln -s /opt/zig/zig /usr/local/bin/zig; \ + rm -f /tmp/zig.tar.xz + +RUN cargo install --locked queso \ + && cargo install cargo-zigbuild + +RUN gleam --version \ + && rustup --version \ + && zig version \ + && queso --version \ + && cargo-zigbuild --version + +WORKDIR /build + +CMD ["gleam", "build"] diff --git a/README.md b/README.md index fe53400..0149117 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,11 @@ does not need Erlang, Gleam, Zig, or Queso. ### CI artifacts Every push runs the native build in Gitea Actions after formatting succeeds. +The binary build uses the prebuilt +`jaypoch/luma-markdown-builder:latest` image, which contains Gleam, Rust, +rustup, Zig, Queso, and `cargo-zigbuild`. The image definition is in +[`Dockerfile.luma-builder`](Dockerfile.luma-builder). + The workflow uploads two downloadable artifacts: - `luma_markdown-linux-x86_64`