Skip to content

Commit

Permalink
build(tiledit): use a docker image to build
Browse files Browse the repository at this point in the history
  • Loading branch information
NoxHarmonium committed Jul 9, 2024
1 parent a888410 commit 69046e5
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 28 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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 }}
33 changes: 5 additions & 28 deletions .github/workflows/sirc-tiledit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
29 changes: 29 additions & 0 deletions sirc-tiledit/docker/README.md
Original file line number Diff line number Diff line change
@@ -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


```


34 changes: 34 additions & 0 deletions sirc-tiledit/docker/builder.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
LABEL version="1.0"
LABEL maintainer="Sean Dawson <contact@seandawson.info>"
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"]
7 changes: 7 additions & 0 deletions sirc-tiledit/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

cd /project
meson setup /builder/build

cd /builder/build
"$@"

0 comments on commit 69046e5

Please sign in to comment.