From 869d11e99d41b89b409bdea171f93dab96c903e2 Mon Sep 17 00:00:00 2001 From: Manu Bretelle Date: Fri, 23 Aug 2024 09:45:45 -0700 Subject: [PATCH 1/4] s390x: Build native actions-runner for s390x Signed-off-by: Manu Bretelle --- s390x-native.Dockerfile | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 s390x-native.Dockerfile diff --git a/s390x-native.Dockerfile b/s390x-native.Dockerfile new file mode 100644 index 0000000..639b315 --- /dev/null +++ b/s390x-native.Dockerfile @@ -0,0 +1,68 @@ +# Self-Hosted IBM Z Github Actions Runner. +ARG UBUNTU_VERSION=focal +# Main image. +FROM s390x/ubuntu:${UBUNTU_VERSION} +# Redefining UBUNTU_VERSION without a value inherits the global default +ARG UBUNTU_VERSION + +RUN apt-get update \ + && apt-get install -y cmake flex bison build-essential libssl-dev ncurses-dev xz-utils bc rsync libguestfs-tools qemu-kvm qemu-utils linux-image-generic zstd binutils-dev elfutils libcap-dev libelf-dev libdw-dev python3-docutils \ + && apt-get install -y g++ libelf-dev \ + && apt-get install -y iproute2 iputils-ping \ + && apt-get install -y cpu-checker qemu-kvm qemu-utils qemu-system-x86 qemu-system-s390x qemu-system-arm qemu-guest-agent ethtool keyutils iptables gawk \ + && echo "deb https://apt.llvm.org/${UBUNTU_VERSION}/ llvm-toolchain-${UBUNTU_VERSION} main" > /etc/apt/sources.list.d/llvm.list \ + && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \ + && apt-get update \ + && apt-get install -y clang lld llvm + +## s390x runner native install taken from https://github.com/anup-kodlekere/gaplib +ARG VERSION=2.317.0 +ARG SDK=6 +ARG RUNNERREPO="https://github.com/actions/runner" +RUN apt-get update \ + && apt-get install -y alien + +# copy scripts/patch from anup-kodlekere/gaplib +RUN curl -L https://raw.githubusercontent.com/anup-kodlekere/gaplib/main/build-files/convert-rpm.sh -o /tmp/convert-rpm.sh && chmod 755 /tmp/convert-rpm.sh +RUN curl -L https://raw.githubusercontent.com/anup-kodlekere/gaplib/main/build-files/runner-s390x.patch -o /tmp/runner.patch + +RUN /tmp/convert-rpm.sh ${SDK} + +RUN dpkg --install /tmp/*.deb && \ + rm -rf /tmp/*.deb && \ + echo "Using SDK - `dotnet --version`" + + +RUN cd /tmp && \ + git clone -q ${RUNNERREPO} && \ + cd runner && \ + git checkout v${VERSION} -b build && \ + sed -i'' -e /version/s/6......\"$/${SDK}.0.100\"/ src/global.json && \ + git apply /tmp/runner.patch + +RUN cd /tmp/runner/src && \ + ./dev.sh layout && \ + ./dev.sh package && \ + ./dev.sh test && \ + rm -rf /root/.dotnet /root/.nuget + + +# amd64 Github Actions Runner. +ARG HOMEDIR=/actions-runner +# Copy scripts from myoung34/docker-github-actions-runner +RUN curl -L https://raw.githubusercontent.com/myoung34/docker-github-actions-runner/${VERSION}/entrypoint.sh -o /entrypoint.sh && chmod 755 /entrypoint.sh +RUN curl -L https://raw.githubusercontent.com/myoung34/docker-github-actions-runner/${VERSION}/token.sh -o /token.sh && chmod 755 /token.sh + +RUN useradd -d ${HOMEDIR} -m runner +RUN echo "runner ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers +RUN echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >>/etc/sudoers +# Make sure kvm group exists. This is a no-op when it does. +RUN addgroup --system kvm +RUN usermod -a -G kvm runner +USER runner +ENV USER=runner +WORKDIR ${HOMEDIR} +USER root + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["./bin/Runner.Listener", "run", "--startuptype", "service"] From 8c813c7d5d773c69ba4f60cf1d4a175a9d872881 Mon Sep 17 00:00:00 2001 From: Manu Bretelle Date: Fri, 23 Aug 2024 09:49:32 -0700 Subject: [PATCH 2/4] stop building focal containers Signed-off-by: Manu Bretelle --- .github/workflows/publish.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2e94091..65e3f5f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -39,7 +39,7 @@ jobs: id-token: write strategy: matrix: - ubuntu_version: [focal, noble] + ubuntu_version: [noble] arch: [s390x, aarch64, x86_64] include: - arch: s390x @@ -92,15 +92,6 @@ jobs: latest=auto prefix= suffix=-${{ matrix.ubuntu_version }}-${{ matrix.arch }} - tags: | - # Generate old tag names (e.g main-s390x, main-x86_64...) when building focal - # branch event - type=ref,enable=${{ matrix.ubuntu_version == 'focal' }},suffix=-${{ matrix.arch }},event=branch - # pr event - type=ref,enable=${{ matrix.ubuntu_version == 'focal' }},prefix=pr-,suffix=-${{ matrix.arch }},event=pr - # tags for all pr/branches - type=ref,event=branch,enable=true,priority=600 - type=ref,event=pr,enable=true,prefix=pr-,priority=600 # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action From fa29d7468b15702d88bab7f18bae5a6e23176990 Mon Sep 17 00:00:00 2001 From: Manu Bretelle Date: Fri, 23 Aug 2024 09:50:32 -0700 Subject: [PATCH 3/4] WIP: build native s390x Signed-off-by: Manu Bretelle --- .github/workflows/publish.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 65e3f5f..af35e44 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -40,17 +40,17 @@ jobs: strategy: matrix: ubuntu_version: [noble] - arch: [s390x, aarch64, x86_64] + arch: [s390x] #, aarch64, x86_64] include: - arch: s390x - dockerfile: s390x.Dockerfile + dockerfile: s390x-native.Dockerfile platform: linux/s390x - - arch: aarch64 - dockerfile: Dockerfile - platform: linux/arm64 - - arch: x86_64 - dockerfile: Dockerfile - platform: linux/amd64 + # - arch: aarch64 + # dockerfile: Dockerfile + # platform: linux/arm64 + # - arch: x86_64 + # dockerfile: Dockerfile + # platform: linux/amd64 steps: - name: Checkout repository From 62a294bc80d7b11f239e4a59cd9195b15e6887a0 Mon Sep 17 00:00:00 2001 From: Manu Bretelle Date: Fri, 23 Aug 2024 10:59:09 -0700 Subject: [PATCH 4/4] add more tools --- s390x-native.Dockerfile | 60 +++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/s390x-native.Dockerfile b/s390x-native.Dockerfile index 639b315..18da793 100644 --- a/s390x-native.Dockerfile +++ b/s390x-native.Dockerfile @@ -5,6 +5,15 @@ FROM s390x/ubuntu:${UBUNTU_VERSION} # Redefining UBUNTU_VERSION without a value inherits the global default ARG UBUNTU_VERSION +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get -y install \ + git \ + jq \ + sudo \ + tree \ + wget && \ + apt-get clean + RUN apt-get update \ && apt-get install -y cmake flex bison build-essential libssl-dev ncurses-dev xz-utils bc rsync libguestfs-tools qemu-kvm qemu-utils linux-image-generic zstd binutils-dev elfutils libcap-dev libelf-dev libdw-dev python3-docutils \ && apt-get install -y g++ libelf-dev \ @@ -13,56 +22,55 @@ RUN apt-get update \ && echo "deb https://apt.llvm.org/${UBUNTU_VERSION}/ llvm-toolchain-${UBUNTU_VERSION} main" > /etc/apt/sources.list.d/llvm.list \ && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \ && apt-get update \ - && apt-get install -y clang lld llvm + && apt-get install -y clang lld llvm \ + && apt-get clean + +# Create Github Actions Runner user. +ARG HOMEDIR=/actions-runner +WORKDIR ${HOMEDIR} +RUN useradd -d ${HOMEDIR} -m runner +RUN echo "runner ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers +RUN echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >>/etc/sudoers +# Make sure kvm group exists. This is a no-op when it does. +RUN addgroup --system kvm +RUN usermod -a -G kvm runner +RUN chown -R runner:runner ${HOMEDIR} + ## s390x runner native install taken from https://github.com/anup-kodlekere/gaplib -ARG VERSION=2.317.0 +ARG VERSION=2.319.1 ARG SDK=6 ARG RUNNERREPO="https://github.com/actions/runner" RUN apt-get update \ - && apt-get install -y alien + && apt-get install -y alien \ + && apt-get clean # copy scripts/patch from anup-kodlekere/gaplib RUN curl -L https://raw.githubusercontent.com/anup-kodlekere/gaplib/main/build-files/convert-rpm.sh -o /tmp/convert-rpm.sh && chmod 755 /tmp/convert-rpm.sh RUN curl -L https://raw.githubusercontent.com/anup-kodlekere/gaplib/main/build-files/runner-s390x.patch -o /tmp/runner.patch -RUN /tmp/convert-rpm.sh ${SDK} - -RUN dpkg --install /tmp/*.deb && \ - rm -rf /tmp/*.deb && \ +RUN /tmp/convert-rpm.sh ${SDK} && \ + dpkg --install /tmp/*.deb && \ + rm -rf /tmp/*.{rpm,deb} && \ echo "Using SDK - `dotnet --version`" - RUN cd /tmp && \ git clone -q ${RUNNERREPO} && \ cd runner && \ git checkout v${VERSION} -b build && \ sed -i'' -e /version/s/6......\"$/${SDK}.0.100\"/ src/global.json && \ - git apply /tmp/runner.patch - -RUN cd /tmp/runner/src && \ + git apply /tmp/runner.patch && \ + cd src && \ ./dev.sh layout && \ ./dev.sh package && \ ./dev.sh test && \ - rm -rf /root/.dotnet /root/.nuget - + rm -rf /root/.dotnet /root/.nuget && \ + sudo -u runner tar -C ${HOMEDIR} -xzf /tmp/runner/_package/actions-runner-linux-s390x-${VERSION}.tar.gz && \ + rm -rf /tmp/runner -# amd64 Github Actions Runner. -ARG HOMEDIR=/actions-runner # Copy scripts from myoung34/docker-github-actions-runner RUN curl -L https://raw.githubusercontent.com/myoung34/docker-github-actions-runner/${VERSION}/entrypoint.sh -o /entrypoint.sh && chmod 755 /entrypoint.sh RUN curl -L https://raw.githubusercontent.com/myoung34/docker-github-actions-runner/${VERSION}/token.sh -o /token.sh && chmod 755 /token.sh -RUN useradd -d ${HOMEDIR} -m runner -RUN echo "runner ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers -RUN echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >>/etc/sudoers -# Make sure kvm group exists. This is a no-op when it does. -RUN addgroup --system kvm -RUN usermod -a -G kvm runner -USER runner -ENV USER=runner -WORKDIR ${HOMEDIR} -USER root - ENTRYPOINT ["/entrypoint.sh"] CMD ["./bin/Runner.Listener", "run", "--startuptype", "service"]