From 9a51437ab0d189d3ee87be2d72b1236f384fa7d9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 11 Sep 2021 16:27:17 +0000 Subject: [PATCH] feat: Build Docker image in CI --- .gitlab-ci.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e17b28b2..6a9d58c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -261,3 +261,46 @@ release: --assets-link "{\"name\":\"fluffychat-linux-arm64.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/fluffychat-linux-arm64.tar.gz\"}" \ --assets-link "{\"name\":\"fluffychat-windows.zip\",\"url\":\"${PACKAGE_REGISTRY_URL}/fluffychat-windows.zip\"}" \ --assets-link "{\"name\":\"fluffychat-web.tar.gz\",\"url\":\"${PACKAGE_REGISTRY_URL}/fluffychat-web.tar.gz\"}" + +.docker: &docker_template + image: docker:latest + tags: + - docker + - famedly + stage: deploy + services: + - docker:dind + +docker-releases: + <<: *docker_template + script: + - docker build --pull -t "${CI_REGISTRY_IMAGE}:latest" -t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" . + - docker push "${CI_REGISTRY_IMAGE}:latest" + - docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" + rules: + - if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/' + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + +docker-tags: + <<: *docker_template + script: + - docker build --pull -t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" . + - docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" + rules: + - if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG !~ /^v\d+\.\d+\.\d+$/' + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + +docker-branches: + <<: *docker_template + script: + - docker build --pull -t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}" -t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}" . + - docker push "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}" + rules: + - if: $CI_COMMIT_TAG == null + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + allow_failure: true + +