Skip to content
Snippets Groups Projects
.gitlab-ci.yml 14.14 KiB
stages:
  - test
  - release
  - build

services:
  - name: griefed/gitlab-ci-cd:2.0.5
    alias: docker
    command: ["--experimental"]

image: griefed/gitlab-ci-cd:2.0.5

variables:
  project_name: $CI_PROJECT_NAME
  SEMANTIC_RELEASE_PACKAGE: $CI_PROJECT_NAME
  FOCAL_RELEASE_DATE: "current"
  OVERLAY_VERSION: "v2.2.0.3"

test docker:
  stage: test
  before_script:
    - docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_TOKEN" docker.io
    - docker login -u "$DOCKERHUB_USER" -p "$GITHUB_TOKEN" ghcr.io
  script:
    - echo "**** Build amd64 ****"
    - docker build
      --no-cache
      --tag "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:amd64-develop"
      --tag "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:amd64-develop"
      --build-arg FOCAL_ARCH=amd64
      --build-arg FOCAL_RELEASE_DATE="$FOCAL_RELEASE_DATE"
      --build-arg BUILD_DATE="$CI_PIPELINE_CREATED_AT"
      --build-arg VERSION="$CI_COMMIT_SHORT_SHA"
      --build-arg OVERLAY_VERSION="$OVERLAY_VERSION"
      --build-arg OVERLAY_ARCH=amd64 .
    - docker push "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:amd64-develop"
    - docker push "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:amd64-develop"
    - echo "**** Build armhf ****"
    - docker build
      --no-cache
      --tag "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:armhf-develop"
      --tag "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:armhf-develop"
      --build-arg FOCAL_ARCH=armhf
      --build-arg FOCAL_RELEASE_DATE="$FOCAL_RELEASE_DATE"
      --build-arg BUILD_DATE="$CI_PIPELINE_CREATED_AT"
      --build-arg VERSION="$CI_COMMIT_SHORT_SHA"
      --build-arg OVERLAY_VERSION="$OVERLAY_VERSION"
      --build-arg OVERLAY_ARCH=arm .
    - docker push "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:armhf-develop"
    - docker push "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:armhf-develop"
    - echo "**** Build arm64 ****"
    - docker build
      --no-cache
      --tag "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:arm64-develop"
      --tag "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:arm64-develop"
      --build-arg FOCAL_ARCH=arm64
      --build-arg FOCAL_RELEASE_DATE="$FOCAL_RELEASE_DATE"
      --build-arg BUILD_DATE="$CI_PIPELINE_CREATED_AT"
      --build-arg VERSION="$CI_COMMIT_SHORT_SHA"
      --build-arg OVERLAY_VERSION="$OVERLAY_VERSION"
      --build-arg OVERLAY_ARCH=aarch64 .
    - docker push "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:arm64-develop"
    - docker push "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:arm64-develop"
    - echo "**** Create DockerHub manifest ****"
    - docker manifest create "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:develop" "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:amd64-develop" "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:armhf-develop" "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:arm64-develop"
    - docker manifest annotate "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:develop" "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:armhf-develop" --os linux --arch arm
    - docker manifest annotate "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:develop" "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:arm64-develop" --os linux --arch arm64 --variant v8
    - docker manifest push --purge "index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:develop"
    - echo "**** Create GitHub manifest ****"
    - docker manifest create "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:develop" "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:amd64-develop" "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:armhf-develop" "ghcr.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:arm64-develop"