From ca59cbeec2a750ee67e8542f3c1292deb1aa156e Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Sun, 28 Jul 2024 20:02:39 +0200 Subject: [PATCH] CI: build docker image for Linux ARM build and cache layers --- .github/workflows/ci.yml | 20 ++++++++++++++------ docker/Dockerfile | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 docker/Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e6506df6b..38bdef4ab5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,15 +103,23 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Build compiler binaries - uses: docker://ghcr.io/rescript-lang/rescript-ci-build:alpine-3.20-ocaml-5.2.0-01 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + uses: docker/build-push-action@v6 with: - args: opam exec -- dune build --display quiet --profile static + context: ./docker + tags: rescript-ci-build:latest + load: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build compiler binaries + run: docker run --rm -v ${{ github.workspace }}:/data -w /data rescript-ci-build:latest opam exec -- dune build --display quiet --profile static - name: Build ninja binary - uses: docker://ghcr.io/rescript-lang/rescript-ci-build:alpine-3.20-ocaml-5.2.0-01 - with: - args: sh -c "cd ninja && LDFLAGS=-static python configure.py --bootstrap" + run: docker run --rm -v ${{ github.workspace }}:/data -w /data/ninja -e LDFLAGS="-static" rescript-ci-build:latest python configure.py --bootstrap - name: Use Node.js uses: actions/setup-node@v4 diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000..b344d017dc --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine:3.20 +LABEL org.opencontainers.image.authors="Christoph Knittel " +LABEL org.opencontainers.image.description="Alpine-based Docker image for building statically linked ReScript binaries." + +# - gcompat needed for ARM64, see https://github.com/actions/runner/issues/801#issuecomment-1374967227 +# - python3 needed for ninja build +RUN apk add --no-cache bash gcc g++ git make opam python3 rsync gcompat + +# We need to specify the OPAM dir explicitly as the GitHub Actions runner +# will set a different home directory when running in a container. +ENV OPAMROOT=/root/.opam + +RUN opam init -y --compiler=5.2.0 --disable-sandboxing + +RUN opam install -y dune cppo=1.6.9 ounit2=2.2.7