From b982f51ae3ea263c4d8ed611f1bd892a8fb9ecd3 Mon Sep 17 00:00:00 2001 From: Jean Felder Date: Tue, 18 Jun 2024 16:34:33 +0200 Subject: [PATCH] ci: Build a debian docker image --- .gitlab-ci.yml | 1 + .gitlab/pipeline/build-debian.yml | 69 +++++++++++++++++++++++++++++++ .gitlab/pipeline/debian.yml | 7 +--- docker/dockerfile.debian | 12 ++++++ 4 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 .gitlab/pipeline/build-debian.yml create mode 100644 docker/dockerfile.debian diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 92874bcc..aaef7457 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,6 +30,7 @@ include: - local: /.gitlab/pipeline/sonar.yml - local: /.gitlab/pipeline/lint-code.yml - local: /.gitlab/pipeline/test-code.yml + - local: /.gitlab/pipeline/build-debian.yml - local: /.gitlab/pipeline/build-windows.yml sast: diff --git a/.gitlab/pipeline/build-debian.yml b/.gitlab/pipeline/build-debian.yml new file mode 100644 index 00000000..030c3b2b --- /dev/null +++ b/.gitlab/pipeline/build-debian.yml @@ -0,0 +1,69 @@ +build:debian-stable: + stage: build + image: docker:latest + services: + - name: docker:dind + rules: + # on default branch + - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH + when: always + # on a tag + - if: $CI_COMMIT_TAG + when: always + # on a MR if previous jobs are successful + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + when: always + variables: + CGAL_VERSION: "5.6" + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - docker pull $CI_REGISTRY_IMAGE:debian-stable-latest || true + - docker build + --pull + --cache-from $CI_REGISTRY_IMAGE:debian-stable-latest + --tag $CI_REGISTRY_IMAGE:debian-stable-$CI_COMMIT_SHA + -f docker/Dockerfile.debian + . + - docker push $CI_REGISTRY_IMAGE:debian-stable-$CI_COMMIT_SHA + after_script: + - docker logout $env:CI_REGISTRY + +push:debian-stable-latest: + stage: deploy + image: docker:latest + services: + - name: docker:dind + variables: + GIT_STRATEGY: none + only: + refs: + - main + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - docker pull $CI_REGISTRY_IMAGE:debian-stable-$CI_COMMIT_SHA + - docker tag $CI_REGISTRY_IMAGE:debian-stable-$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:debian-stable-latest + - docker push $CI_REGISTRY_IMAGE:debian-stable-latest + after_script: + - docker logout $CI_REGISTRY + + +push:debian-stable-tag: + stage: deploy + image: docker:latest + services: + - name: docker:dind + variables: + GIT_STRATEGY: none + only: + refs: + - tags + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - docker pull $CI_REGISTRY_IMAGE:debian-stable-$CI_COMMIT_SHA + - docker tag $CI_REGISTRY_IMAGE:debian-stable-$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:debian-stable-$CI_COMMIT_REF_NAME + - docker push $CI_REGISTRY_IMAGE:debian-stable-$CI_COMMIT_REF_NAME + after_script: + - docker logout $CI_REGISTRY diff --git a/.gitlab/pipeline/debian.yml b/.gitlab/pipeline/debian.yml index fc4ea3a5..2fcce9b9 100644 --- a/.gitlab/pipeline/debian.yml +++ b/.gitlab/pipeline/debian.yml @@ -16,15 +16,10 @@ debian_testing_gcc: debian_bullseye_gcc: stage: test - image: debian:bullseye + image: ${CI_REGISTRY_IMAGE}/debian-stable-$CI_COMMIT_SHA script: - - apt-get update -qq - - apt-get install --yes sudo wget build-essential - - ./ci/debian/before_install.sh $CGAL_VERSION - cd $CI_PROJECT_DIR - - CGAL_DIR=$CI_PROJECT_DIR/CGAL cmake -DSFCGAL_BUILD_TESTS=ON -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ - - make - ctest -VV parallel: matrix: diff --git a/docker/dockerfile.debian b/docker/dockerfile.debian new file mode 100644 index 00000000..dd3d7b35 --- /dev/null +++ b/docker/dockerfile.debian @@ -0,0 +1,12 @@ +FROM debian:bullseye + +COPY ./ci/debian/before_install.sh before_install.sh + +RUN apt-get update -qq && \ + apt-get install --yes sudo wget build-essential + +RUN ./ci/debian/before_install.sh $CGAL_VERSION && \ + rm -f install.sh + +RUN CGAL_DIR=/CGAL cmake -DSFCGAL_BUILD_TESTS=ON -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ && \ + make