diff --git a/.docker/build/Dockerfile b/.docker/build/Dockerfile new file mode 100644 index 000000000..543794bc5 --- /dev/null +++ b/.docker/build/Dockerfile @@ -0,0 +1,26 @@ +# Dockerfile for gvm-libs-$VERSION-$COMPILER-build + +# Define ARG we use through the build +ARG VERSION=master +ARG BUILD_TYPE=Debug +ARG COMPILER=gcc + +FROM greenbone/gvm-libs-$VERSION-$COMPILER-testing + +# This will make apt-get install without question +ARG DEBIAN_FRONTEND=noninteractive + +# Define ARG we use through the build +ARG VERSION +ARG BUILD_TYPE +ARG COMPILER + +COPY . /usr/local/src/gvm-libs +WORKDIR /usr/local/src + +# clone and install gvm-libs +RUN cd gvm-libs && \ + mkdir build && \ + cd build && \ + cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .. && \ + make install diff --git a/.docker/deploy/clang/Dockerfile b/.docker/deploy/clang/Dockerfile deleted file mode 100644 index d696d1989..000000000 --- a/.docker/deploy/clang/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# gvm-libs-gvm-libs-21.04-debian-buster-gcc-test - -# Use '-slim' image for reduced image size -FROM debian:buster-slim - -# Provides a Debian buster image with the core build dependencies for gvm-libs -LABEL module="gvm-libs" -LABEL branch="gvm-libs-21.04" -LABEL platform="debian-buster" -LABEL compiler="clang" -LABEL configuration="deploy" - -# This will make apt-get install without question -ARG DEBIAN_FRONTEND=noninteractive - -# Install core dependencies required for building gvm-libs -RUN apt-get update && apt-get install --assume-yes \ - clang \ - clang-format \ - clang-tools \ - cmake \ - git \ - libglib2.0-dev \ - libgnutls28-dev \ - libgpgme-dev \ - libhiredis-dev \ - libpcap-dev \ - libnet1-dev \ - libssh-gcrypt-dev \ - libxml2-dev \ - pkg-config \ - uuid-dev \ - libssl-dev \ - && rm -rf /var/lib/apt/lists/* - -# clone and install gvm-libs -RUN git clone --depth 1 \ - https://github.com/greenbone/gvm-libs.git \ - -b gvm-libs-21.04 && \ - cd gvm-libs && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_BUILD_TYPE=Release .. && \ - make install diff --git a/.docker/deploy/gcc/Dockerfile b/.docker/deploy/gcc/Dockerfile deleted file mode 100644 index 67306608e..000000000 --- a/.docker/deploy/gcc/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -# gvm-libs-gvm-libs-21.04-debian-buster-gcc-deploy - -# Use '-slim' image for reduced image size -FROM debian:buster-slim - -# Provides a Debian buster image with the core build dependencies for gvm-libs -LABEL module="gvm-libs" -LABEL branch="gvm-libs-21.04" -LABEL platform="debian-buster" -LABEL compiler="gcc" -LABEL configuration="deploy" - -# This will make apt-get install without question -ARG DEBIAN_FRONTEND=noninteractive - -# Install core dependencies required for building gvm-libs -RUN apt-get update && apt-get install --no-install-recommends --assume-yes \ - ca-certificates \ - cmake \ - gcc \ - git \ - libglib2.0-dev \ - libgnutls28-dev \ - libgpgme-dev \ - libhiredis-dev \ - libpcap-dev \ - libssh-gcrypt-dev \ - libxml2-dev \ - libnet1-dev \ - make \ - pkg-config \ - uuid-dev \ - libssl-dev \ - && rm -rf /var/lib/apt/lists/* - -# clone and install gvm-libs -RUN git clone --depth 1 \ - https://github.com/greenbone/gvm-libs.git \ - -b gvm-libs-21.04 && \ - cd gvm-libs && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_BUILD_TYPE=Release .. && \ - make install diff --git a/.docker/test/clang/Dockerfile b/.docker/test/clang/Dockerfile deleted file mode 100644 index cffed4b51..000000000 --- a/.docker/test/clang/Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ -# gvm-libs-gvm-libs-21.04-debian-buster-gcc-test - -# Use '-slim' image for reduced image size -FROM debian:buster-slim - -# Provides a Debian buster image with the core build dependencies for gvm-libs -LABEL module="gvm-libs" -LABEL branch="gvm-libs-21.04" -LABEL platform="debian-buster" -LABEL compiler="clang" -LABEL configuration="test" - -# This will make apt-get install without question -ARG DEBIAN_FRONTEND=noninteractive - -# Install core dependencies required for building gvm-libs -RUN apt-get update && apt-get install --assume-yes \ - clang \ - clang-format \ - clang-tools \ - cmake \ - git \ - libglib2.0-dev \ - libgnutls28-dev \ - libgpgme-dev \ - libhiredis-dev \ - libpcap-dev \ - libnet1-dev \ - libssh-gcrypt-dev \ - libxml2-dev \ - pkg-config \ - uuid-dev \ - libssl-dev \ - && rm -rf /var/lib/apt/lists/* - -# Install Debian core dependencies required for testing gvm-libs -# support and not yet installed as dependencies of gvm-libs-core -RUN apt-get update && apt-get install --assume-yes \ - lcov \ - libical-dev \ - libpq-dev \ - libnet1-dev \ - postgresql-server-dev-all \ - xsltproc \ - && rm -rf /var/lib/apt/lists/* - -# install cgreen for unit tests -RUN git clone --depth 1 https://github.com/cgreen-devs/cgreen.git \ - && cd cgreen \ - && make \ - && make test \ - && make install \ - && cd .. \ - && rm -rf cgreen - -ENV LD_LIBRARY_PATH="/usr/local/lib" diff --git a/.docker/test/gcc/Dockerfile b/.docker/test/gcc/Dockerfile deleted file mode 100644 index 1252e2326..000000000 --- a/.docker/test/gcc/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -# gvm-libs-gvm-libs-21.04-debian-buster-gcc-test - -# Use '-slim' image for reduced image size -FROM debian:buster-slim - -# Provides a Debian buster image with the core build dependencies for gvm-libs -LABEL module="gvm-libs" -LABEL branch="gvm-libs-21.04" -LABEL platform="debian-buster" -LABEL compiler="gcc" -LABEL configuration="test" - -# This will make apt-get install without question -ARG DEBIAN_FRONTEND=noninteractive - -# Install core dependencies required for building gvm-libs -RUN apt-get update && apt-get install --no-install-recommends --assume-yes \ - ca-certificates \ - cmake \ - gcc \ - git \ - libglib2.0-dev \ - libgnutls28-dev \ - libgpgme-dev \ - libhiredis-dev \ - libpcap-dev \ - libssh-gcrypt-dev \ - libxml2-dev \ - libnet1-dev \ - make \ - pkg-config \ - uuid-dev \ - libssl-dev \ - && rm -rf /var/lib/apt/lists/* - -# Install Debian core dependencies required for testing gvm-libs -# support and not yet installed as dependencies of gvm-libs-core -RUN apt-get update && apt-get install --assume-yes \ - g++ \ - lcov \ - libical-dev \ - libpq-dev \ - libnet1-dev \ - postgresql-server-dev-all \ - xsltproc \ - && rm -rf /var/lib/apt/lists/* - -# install cgreen for unit tests -RUN git clone --depth 1 https://github.com/cgreen-devs/cgreen.git \ - && cd cgreen \ - && make \ - && make test \ - && make install \ - && cd .. \ - && rm -rf cgreen - -ENV LD_LIBRARY_PATH="/usr/local/lib" diff --git a/.docker/testing/Dockerfile b/.docker/testing/Dockerfile new file mode 100644 index 000000000..b3c9bf856 --- /dev/null +++ b/.docker/testing/Dockerfile @@ -0,0 +1,81 @@ +# Dockerfile for gvm-libs-$VERSION-$COMPILER-testing + +# Define ARG we use through the build +ARG VERSION=master +ARG BUILD_TYPE=Debug +ARG COMPILER=gcc + +# Use '-slim' image for reduced image size +FROM debian:buster-slim + +# This will make apt-get install without question +ARG DEBIAN_FRONTEND=noninteractive + +# Redefine ARG we use through the build +ARG VERSION +ARG BUILD_TYPE +ARG COMPILER + +WORKDIR /usr/local/src + +# Install core dependencies required for building and testing gvm-libs +RUN apt-get update \ + && apt-get install --no-install-recommends --assume-yes \ + ca-certificates \ + cmake \ + git \ + libglib2.0-dev \ + libgnutls28-dev \ + libgpgme-dev \ + libhiredis-dev \ + libpcap-dev \ + libssh-gcrypt-dev \ + libxml2-dev \ + libnet1-dev \ + make \ + pkg-config \ + uuid-dev \ + libssl-dev \ + lcov \ + && rm -rf /var/lib/apt/lists/* + +# Install gcc/g++ compiler +RUN if ( test "$COMPILER" = "gcc"); then \ + echo "Compiler is $COMPILER" \ + && apt-get update \ + && apt-get install --no-install-recommends --assume-yes gcc g++; \ + fi + +# Install clang compiler +RUN if ( test "$COMPILER" = "clang"); then \ + echo "Compiler is $COMPILER" \ + && apt-get update \ + && apt-get install --no-install-recommends --assume-yes \ + clang \ + clang-format \ + clang-tools; \ + fi + +# clone and install mqtt paho +# workaround otherwise paho.mqtt.c creates man1 as a file +RUN if ( test "$VERSION" = "master" || test "$VERSION" = "middleware" ); then \ + echo "Verion is $VERSION" \ + && mkdir /usr/local/share/man/man1 \ + && git clone --depth 1 https://github.com/eclipse/paho.mqtt.c \ + && cd paho.mqtt.c \ + && make \ + && make install \ + && cd .. \ + && rm -rf paho.mqtt.c; \ + fi + +# & install cgreen for unit tests +RUN git clone --depth 1 https://github.com/cgreen-devs/cgreen.git \ + && cd cgreen \ + && make \ + && make test \ + && make install \ + && cd .. \ + && rm -rf cgreen + +ENV LD_LIBRARY_PATH="/usr/local/lib" diff --git a/.github/workflows/ci-c.yml b/.github/workflows/ci-c.yml index 4b812ee83..00f526172 100644 --- a/.github/workflows/ci-c.yml +++ b/.github/workflows/ci-c.yml @@ -24,14 +24,14 @@ jobs: strategy: matrix: container: - - greenbone/gvm-libs-gvm-libs-21.04-debian-buster-clang-test - - greenbone/gvm-libs-gvm-libs-21.04-debian-buster-gcc-test + - greenbone/gvm-libs-21.04-clang-testing + - greenbone/gvm-libs-21.04-gcc-testing container: ${{ matrix.container }} steps: - uses: actions/checkout@v2.3.4 - name: Configure and test gvm-libs run: | - mkdir build && cd build/ && cmake -DCMAKE_BUILD_TYPE=Release \ + mkdir build && cd build/ && cmake -DCMAKE_BUILD_TYPE=Debug \ -DBUILD_TESTS=1 .. && make install && make tests && \ CTEST_OUTPUT_ON_FAILURE=1 make test working-directory: ${{ github.WORKSPACE }} @@ -42,8 +42,8 @@ jobs: strategy: matrix: container: - - greenbone/gvm-libs-gvm-libs-21.04-debian-buster-clang-test - - greenbone/gvm-libs-gvm-libs-21.04-debian-buster-gcc-test + - greenbone/gvm-libs-21.04-clang-testing + - greenbone/gvm-libs-21.04-gcc-testing container: ${{ matrix.container }} steps: - uses: actions/checkout@v2.3.4 @@ -56,7 +56,7 @@ jobs: scan_build: name: Scan-build gvm-libs with clang runs-on: 'ubuntu-latest' - container: greenbone/gvm-libs-gvm-libs-21.04-debian-buster-clang-test + container: greenbone/gvm-libs-21.04-clang-testing steps: - uses: actions/checkout@v2.3.4 - name: Configure and Compile gvm-libs diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml index b8973b1bf..e4d0d7e12 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-ci.yml @@ -2,32 +2,83 @@ name: Build and upload docker images on: push: - branches: - - 'gvm-libs-21.04' + branches: [ master, gvm-libs-20.08, gvm-libs-21.04, middleware ] jobs: - build-master-gcc-test: + upload-testing: + name: "Upload testing docker images" runs-on: ubuntu-latest strategy: matrix: - compiler: - - gcc - - clang - purpose: - - test - - deploy - platform: - - debian-buster - + compiler: + - gcc + - clang steps: - name: Checkout uses: actions/checkout@v2 - name: Find reference branch run: | - if [ -n "$GITHUB_BASE_REF" ]; \ + echo $GITHUB_BASE_REF + echo $GITHUB_REF + if [ -n "$GITHUB_BASE_REF" ]; \ then echo "BRANCH=${GITHUB_BASE_REF##*/}" >> $GITHUB_ENV; \ else echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV; \ - fi + fi; \ + - name: Find version + run: | + echo $BRANCH + if [ $BRANCH = "master" ]; \ + then VERSION=master; \ + else VERSION=$(echo "$BRANCH" | sed 's/gvm-libs-//g' -); \ + fi; + echo "VERSION=$VERSION" >> $GITHUB_ENV + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # this only works with github.ref on push not on pull_request. ;) + - run: echo "Build and push ${{ github.repository }}-${{ env.VERSION }}-${{matrix.compiler}}-testing" + - name: Build and push + uses: docker/build-push-action@v2.5.0 + with: + context: . + push: true + tags: ${{ github.repository }}-${{ env.VERSION }}-${{matrix.compiler}}-testing + file: .docker/testing/Dockerfile + build-args: | + VERSION=${{ env.VERSION }} + COMPILER=${{matrix.compiler}} + upload-build: + needs: upload-testing + name: "Upload build docker images" + runs-on: ubuntu-latest + strategy: + matrix: + compiler: + - gcc + - clang + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Find reference branch + run: | + echo $GITHUB_BASE_REF + echo $GITHUB_REF + if [ -n "$GITHUB_BASE_REF" ]; \ + then echo "BRANCH=${GITHUB_BASE_REF##*/}" >> $GITHUB_ENV; \ + else echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV; \ + fi; \ + - name: Find version + run: | + echo $BRANCH + if [ $BRANCH = "master" ]; \ + then VERSION=master; \ + else VERSION=$(echo "$BRANCH" | sed 's/gvm-libs-//g' -); \ + fi; + echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Login to DockerHub @@ -36,10 +87,14 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} # this only works with github.ref on push not on pull_request. ;) - - run: echo "Build and push ${{ github.repository }}-${{ env.BRANCH }}-${{ matrix.platform}}-${{matrix.compiler}}-${{matrix.purpose}}" + - run: echo "Build and push ${{ github.repository }}-${{ env.VERSION }}-${{matrix.compiler}}-build" - name: Build and push uses: docker/build-push-action@v2.5.0 with: + context: . push: true - tags: ${{ github.repository }}-${{ env.BRANCH }}-${{ matrix.platform}}-${{matrix.compiler}}-${{matrix.purpose}} - file: .docker/${{matrix.purpose}}/${{matrix.compiler}}/Dockerfile + tags: ${{ github.repository }}-${{ env.VERSION }}-${{matrix.compiler}}-build + file: .docker/build/Dockerfile + build-args: | + VERSION=${{ env.VERSION }} + COMPILER=${{matrix.compiler}}