From e5014c564c0cef17dd8aa56139393952a4fe2b52 Mon Sep 17 00:00:00 2001 From: gangatp <145573667+gangatp@users.noreply.github.com> Date: Wed, 31 Jan 2024 16:10:49 +0530 Subject: [PATCH] Linux build using ubi8 and gcc12 (#338) * adding docker file * adding dockerfile * giving permissions to cmake file * build ubi8 image * adding destination in artifact * using zip instead of tar * ignoring parent folder while zipping * replacing ubuntu with ubi8 binaries * replacing ubuntu with ubi8 binaries * creating artifacts from ubi8 * fixing lib3mf linux export --- .github/workflows/build.yml | 51 +++++++++++++++++++++----- CI/Dockerfile | 72 +++++++++++++++++++++++++++++++++++-- CI/Dockerfile.ubuntu | 18 ++++++++++ CI/script.sh | 7 ---- 4 files changed, 129 insertions(+), 19 deletions(-) create mode 100644 CI/Dockerfile.ubuntu delete mode 100644 CI/script.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ccfd7a37f..96a237c83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,7 @@ on: [push, pull_request] name: Build jobs: - build-linux: + build-linux-memtest: runs-on: ubuntu-20.04 steps: - run: sudo apt update @@ -12,19 +12,53 @@ jobs: - run: sh cmake/GenerateMake.sh - run: cmake --build . --target lib3mf_memcheck working-directory: ./build - - run: ctest -V - working-directory: ./build - - name: Archive Linux binary - uses: actions/upload-artifact@v2 + + build-linux-ubi8-gcc12: + runs-on: ubuntu-20.04 + steps: + - run: sudo apt update + - run: sudo apt install -y uuid-dev + - uses: actions/checkout@v2 with: - name: lib3mf.so - path: build/lib3mf.so.2 + submodules: true + - run: mkdir -p build - run: zip -r build/bindings.zip Autogenerated/Bindings + - name: Archive bindings uses: actions/upload-artifact@v2 with: name: bindings.zip path: build/bindings.zip + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Docker Build + uses: docker/build-push-action@v5 + with: + context: . + file: ./CI/Dockerfile + platforms: linux/amd64 + tags: lib3mf_ubi8:latest + load: true + - + name: Docker Extract + uses: shrink/actions-docker-extract@v3.0.0 + id: extract + with: + image: lib3mf_ubi8:latest + path: out.zip + destination: dist + + - run: unzip out.zip + working-directory: ./dist + - + name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: lib3mf.so + path: dist/lib3mf.so.2 + build-macos: runs-on: macos-latest steps: @@ -41,7 +75,6 @@ jobs: with: name: lib3mf.dylib path: build/lib3mf.dylib - codecoverage-macos: runs-on: macos-latest steps: @@ -141,7 +174,7 @@ jobs: working-directory: ./build assemble-sdk: runs-on: ubuntu-20.04 - needs: [build-windows-release, build-linux, build-macos] + needs: [build-windows-release, build-macos, build-linux-ubi8-gcc12] steps: - run: sudo apt install -y zip unzip - run: mkdir build diff --git a/CI/Dockerfile b/CI/Dockerfile index 3f5d7d56a..846332f66 100644 --- a/CI/Dockerfile +++ b/CI/Dockerfile @@ -1,4 +1,70 @@ -FROM martinweismann/lib3mf_ppcbuilds:latest +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +LABEL maintainer="pradeep.gangatharan@autodesk.com" + +ENV GCCTOOLSET=gcc-toolset-12 + +RUN \ + microdnf update -y && \ + microdnf -y install --nodocs \ + wget \ + which \ + libuuid-devel \ + glibc-langpack-en \ + tar \ + gzip \ + zip \ + ${GCCTOOLSET} \ + && microdnf clean all + +ENV LD_LIBRARY_PATH=/opt/rh/${GCCTOOLSET}/root/usr/lib64:/opt/rh/${GCCTOOLSET}/root/usr/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} +ENV PKG_CONFIG_PATH=/opt/rh/${GCCTOOLSET}/root/usr/lib64/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}} +ENV PATH=/opt/rh/${GCCTOOLSET}/root/usr/bin${PATH:+:${PATH}} + +# CMake +ARG CMAKE_VERSION=3.28.1 +ADD "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz" /usr/tmp/ +RUN tar xzf /usr/tmp/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz -C /opt && rm /usr/tmp/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz +ENV PATH /opt/cmake-$CMAKE_VERSION-linux-x86_64/bin:${PATH} + + +RUN ln -s /opt/cmake-$CMAKE_VERSION-linux-x86_64/bin/cmake /usr/bin/cmake3 +RUN ln -s /opt/cmake-$CMAKE_VERSION-linux-x86_64/bin/cpack /usr/bin/cpack3 +RUN ln -s /opt/cmake-$CMAKE_VERSION-linux-x86_64/bin/ctest /usr/bin/ctest3 + + +RUN ldd --version +RUN cmake --version +RUN cmake3 --version +RUN gcc --version + + ADD . lib3mf-repo -ADD CI/script.sh script.sh -ENTRYPOINT ["sh", "script.sh"] + +WORKDIR "/lib3mf-repo" + +RUN chmod +x cmake/GenerateMake.sh + +RUN cmake/GenerateMake.sh + +WORKDIR "/lib3mf-repo/build" + +RUN cmake --build . + +RUN ctest -V . + +WORKDIR "/../../" + +RUN mkdir -p out + +RUN cp ./lib3mf-repo/build/lib3mf.so.2 ./out/ + +RUN cd out && zip -r ../out.zip . + + + + + + + + diff --git a/CI/Dockerfile.ubuntu b/CI/Dockerfile.ubuntu new file mode 100644 index 000000000..94dec0242 --- /dev/null +++ b/CI/Dockerfile.ubuntu @@ -0,0 +1,18 @@ +# Copy this to root folder of lib3mf then build and run this image. +FROM ubuntu:20.04 + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install build-essential uuid-dev wget + +RUN wget -qO- "https://cmake.org/files/v3.28/cmake-3.28.1-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local + +ADD . lib3mf-repo + +WORKDIR "/lib3mf-repo" + +RUN cmake/GenerateMake.sh + +WORKDIR "/lib3mf-repo/build" + +RUN cmake --build . + +RUN ctest -V . diff --git a/CI/script.sh b/CI/script.sh deleted file mode 100644 index 389ab6362..000000000 --- a/CI/script.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -cd lib3mf-repo -sh cmake/GenerateMakeFast.sh -cd build -make -j1 -ctest -V .