Skip to content
.gitlab-ci.yml 2.2 KiB
Newer Older
nimrod's avatar
nimrod committed
---
include:
  - project: shore/ci-templates
    file: templates/pre-commit.yml
nimrod's avatar
nimrod committed
  - project: shore/ci-templates
    file: templates/notify.yml
nimrod's avatar
nimrod committed

stages:
  - test
  - build
  - deploy

# One day I may want to start tagging release and for that the TAG variable is
# needed, but that would mean releasing ALL of the images when tagging (sort of
# a periodic release). The images are not really related so for now TAG is
# hard-coded to latest.
variables:
  TAG: latest

nimrod's avatar
nimrod committed
# Job templates:

nimrod's avatar
nimrod committed
.build:
  stage: build
  variables:
    DOCKER_BUILDKIT: "1"
  tags: &tags [ns4.shore.co.il]
  script:
nimrod's avatar
nimrod committed
    - docker build --pull --no-cache --iidfile iid "$CONTEXT"
nimrod's avatar
nimrod committed
  after_script:
    - echo "HASH=$(cat iid)" > dot.env
  artifacts:
    reports:
      dotenv: dot.env
  rules: &rules
    - if: $CI_PIPELINE_SOURCE == "schedule"
    - if: $CI_PIPELINE_SOURCE == "push"
      changes:
nimrod's avatar
nimrod committed
        - $CONTEXT/*
        - $CONTEXT/**/*
nimrod's avatar
nimrod committed

.push:
  stage: deploy
  tags: *tags
  script:
nimrod's avatar
nimrod committed
    - docker tag "$HASH" "registry.shore.co.il/$IMAGE:${TAG:-latest}"
    - docker push "registry.shore.co.il/$IMAGE:${TAG:-latest}"
nimrod's avatar
nimrod committed
  rules: *rules

nimrod's avatar
nimrod committed
# cgit image:

nimrod's avatar
nimrod committed
build-cgit:
  extends: .build
  variables:
nimrod's avatar
nimrod committed
    CONTEXT: cgit
nimrod's avatar
nimrod committed

push-cgit:
  extends: .push
  variables:
nimrod's avatar
nimrod committed
    CONTEXT: cgit
nimrod's avatar
nimrod committed
    IMAGE: cgit
  needs:
    - job: build-cgit
      artifacts: true
nimrod's avatar
nimrod committed

nimrod's avatar
nimrod committed
# httpd latest image:
nimrod's avatar
nimrod committed

build-httpd:
  extends: .build
  variables:
nimrod's avatar
nimrod committed
    CONTEXT: httpd/buster
nimrod's avatar
nimrod committed

push-httpd:
  extends: .push
  variables:
nimrod's avatar
nimrod committed
    CONTEXT: httpd/buster
nimrod's avatar
nimrod committed
    IMAGE: httpd
  needs:
    - job: build-httpd
      artifacts: true
nimrod's avatar
nimrod committed

# httpd buster image:

push-httpd-buster:
  extends: .push
  variables:
nimrod's avatar
nimrod committed
    CONTEXT: httpd/buster
nimrod's avatar
nimrod committed
    IMAGE: httpd
    TAG: buster
  needs:
    - job: build-httpd
      artifacts: true
nimrod's avatar
nimrod committed

# httpd bullseye image:

build-httpd-bullseye:
  extends: .build
  variables:
    CONTEXT: httpd/bullseye

push-httpd-bullseye:
  extends: .push
  variables:
nimrod's avatar
nimrod committed
    CONTEXT: httpd/bullseye
nimrod's avatar
nimrod committed
    IMAGE: httpd
    TAG: bullseye
  needs:
    - job: build-httpd-bullseye
      artifacts: true
nimrod's avatar
nimrod committed

# sshd image:

build-sshd:
  extends: .build
  variables:
    CONTEXT: sshd
nimrod's avatar
nimrod committed
    DOCKER_BUILDKIT: ""
nimrod's avatar
nimrod committed

push-sshd:
  extends: .push
  variables:
nimrod's avatar
nimrod committed
    CONTEXT: sshd
nimrod's avatar
nimrod committed
    IMAGE: sshd
  needs:
    - job: build-sshd
      artifacts: true