diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..b449624 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,42 @@ +name: Build Docker image + +# Based on https://github.com/Delgan/qml-format/blob/a57ccf9991ca3e210d2ec3c97156c5fb4bb66227/.github/workflows/docker.yml (Thanks!) + +on: + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}-tiledit-build + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: sirc-tiledit/docker/builder.Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/sirc-tiledit.yml b/.github/workflows/sirc-tiledit.yml index 072e219..ab3780b 100644 --- a/.github/workflows/sirc-tiledit.yml +++ b/.github/workflows/sirc-tiledit.yml @@ -17,6 +17,8 @@ jobs: build: name: Build and Test on ${{ matrix.os }} with Meson v${{ matrix.meson_version }} runs-on: ${{ matrix.os }} + container: + image: ghcr.io/noxharmonium/sirc-tiledit-build:main strategy: matrix: os: [ubuntu-24.04] @@ -26,39 +28,14 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - - name: Remove old LLVM - run: | - sudo apt-get purge clang-format-14 clang-tidy-14 clang-tools-14 clang-14 clangd-14 libc++1-14 libc++abi1-14 libclang1-14 libomp5-14 lld-14 lldb-14 llvm-14 python3-clang-14 - - name: Install up-to-date LLVM - run: | - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh 18 all - # TODO: Surely there is an easier way to set default version - ln -s $(which clang-tidy-18) /usr/local/bin/clang-tidy - ln -s $(which clang-format-18) /usr/local/bin/clang-format - - name: Install ubuntu dependencies + - name: Set ownership run: | - sudo apt-get install libpng-dev - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - name: Install Qt - uses: jurplel/install-qt-action@v4 - with: - version: 6.6.* - - name: Install python based dependencies - run: python -m pip install meson==${{ matrix.meson_version }} ninja gcovr - + # Workaround for https://github.com/actions/runner/issues/2033 + chown -R $(id -u):$(id -g) $PWD - name: Configure Project run: | meson setup -Db_coverage=true --buildtype debug build-debug/ meson setup --buildtype release build-release/ - env: - CC: clang-18 - CXX: clang++-18 - name: Compile Project (Debug) run: | cd build-debug diff --git a/sirc-tiledit/docker/README.md b/sirc-tiledit/docker/README.md new file mode 100644 index 0000000..b036662 --- /dev/null +++ b/sirc-tiledit/docker/README.md @@ -0,0 +1,29 @@ +# Builder Dockerfile + +It was annoying to get a consistent environment to build the project in since +it is currently being developed on Fedora Linux and MacOS and built on Ubuntu. + +This should be the source of truth for the build environment and used as a reference for versions etc. + +# Usage + +## Building it + +From this directory: + +```shell +docker build -t sirc:tiledit-builder -f ./builder.Dockerfile . +``` + +## Using it + +From this directory: + +```shell +podman run --rm -v"$(pwd)/..":/project:z sirc:tiledit-builder meson compile +podman run --rm -v"$(pwd)/..":/project:z sirc:tiledit-builder meson test + + +``` + + diff --git a/sirc-tiledit/docker/builder.Dockerfile b/sirc-tiledit/docker/builder.Dockerfile new file mode 100644 index 0000000..602b164 --- /dev/null +++ b/sirc-tiledit/docker/builder.Dockerfile @@ -0,0 +1,34 @@ +LABEL version="1.0" +LABEL maintainer="Sean Dawson " +LABEL description="This image is used as a consistent environment to build the C++/qt6 based tiledit component of the SIRC project." + +ENV DEBIAN_FRONTEND=noninteractive + +FROM docker.io/library/ubuntu:noble + +RUN apt-get update && \ + apt-get install -y pkg-config libpng-dev qt6-base-dev meson ninja-build gcovr wget software-properties-common && \ + wget https://apt.llvm.org/llvm.sh -P /tmp && \ + chmod +x /tmp/llvm.sh && \ + /tmp/llvm.sh 18 all && \ + # TODO: Surely there is an easier way to set default version + ln -s $(which clang-tidy-18) /usr/local/bin/clang-tidy && \ + ln -s $(which clang-format-18) /usr/local/bin/clang-format && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ENV CC=clang-18 +ENV CXX=clang++-18 + +RUN groupadd -g 10001 builder && \ + useradd -u 10000 -g builder builder && \ + mkdir /builder && \ + chown -R builder:builder /builder + +COPY ./entrypoint.sh /builder/ + +WORKDIR /project + +USER builder:builder + +ENTRYPOINT ["/builder/entrypoint.sh"] \ No newline at end of file diff --git a/sirc-tiledit/docker/entrypoint.sh b/sirc-tiledit/docker/entrypoint.sh new file mode 100755 index 0000000..016c01c --- /dev/null +++ b/sirc-tiledit/docker/entrypoint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +cd /project +meson setup /builder/build + +cd /builder/build +"$@" \ No newline at end of file