Skip to content

Commit

Permalink
ci: Build a debian docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitjano committed Jun 18, 2024
1 parent 8901436 commit b982f51
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
69 changes: 69 additions & 0 deletions .gitlab/pipeline/build-debian.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 1 addition & 6 deletions .gitlab/pipeline/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions docker/dockerfile.debian
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b982f51

Please sign in to comment.