From d04e321b65f2d382eb4a02ec930535fe1fa56db8 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 14 Nov 2023 11:22:25 +0100 Subject: [PATCH] ci: create a docker image with browsercore deps --- .github/workflows/build-deps.yml | 60 ++++++++++++++++++++++++++++++++ Dockerfile.deps | 34 ++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 .github/workflows/build-deps.yml create mode 100644 Dockerfile.deps diff --git a/.github/workflows/build-deps.yml b/.github/workflows/build-deps.yml new file mode 100644 index 00000000..79e3deaf --- /dev/null +++ b/.github/workflows/build-deps.yml @@ -0,0 +1,60 @@ +name: build-deps + +on: + push: + branches: + - "master" + paths: + - 'vendor/lexbor-src/**' + - 'vendor/netsurf/**' + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: browsercore/browsercore-deps + ZIG_VERSION: 0.11.0 + +jobs: + build-deps: + strategy: + matrix: + include: + - os: linux + build_arch: amd64 + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GH_CI_PAT }} + submodules: true + + - name: Docker connect + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Docker build + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + file: Dockerfile.deps + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} + build-args: | + ZIG_VERSION=${{ env.ZIG_VERSION }} + platforms: ${{matrix.os}}/${{matrix.build_arch}} diff --git a/Dockerfile.deps b/Dockerfile.deps new file mode 100644 index 00000000..9bb491ed --- /dev/null +++ b/Dockerfile.deps @@ -0,0 +1,34 @@ +# This dockerfile is used to build browsercore vendor dependencies except +# jsruntime-lib v8. +# jsruntime-lib v8 is built via zig-v8-fork/Dockerfile. +ARG ZIG_VERSION=0.11.0 +FROM ghcr.io/browsercore/zig:${ZIG_VERSION} as build + +# Install required dependencies +RUN apt update && \ + apt install -y git curl bash xz-utils python3 ca-certificates pkg-config \ + libglib2.0-dev gperf libexpat1-dev cmake build-essential + +COPY ./Makefile /src/ +WORKDIR /src + +# build lexbor +ADD ./vendor/lexbor-src /src/vendor/lexbor-src +RUN make install-lexbor + +# build libiconv +RUN make install-libiconv + +# build netsurf +ADD ./vendor/netsurf /src/vendor/netsurf +RUN make install-netsurf + +FROM scratch as artifact + +COPY --from=build /src/vendor/libiconv /usr/local/lib/libiconv + +COPY --from=build /src/vendor/lexbor /usr/local/lib/lexbor + +COPY --from=build /src/vendor/netsurf/build /usr/local/lib/netsurf/build +COPY --from=build /src/vendor/netsurf/lib /usr/local/lib/netsurf/lib +COPY --from=build /src/vendor/netsurf/include /usr/local/lib/netsurf/include