---
include:
  - project: shore/ci-stuff
    file: templates/pre-commit.yml
  - project: shore/ci-stuff
    file: templates/notify.yml
  - project: shore/ci-stuff
    file: templates/containerfiles.yml

# Base image templates:
stages:
  - build-base
  - deploy-base
  - build
  - deploy

.container-build-base:
  extends: .container-build
  stage: build-base

.container-push-base:
  extends: .container-push
  stage: deploy-base

# cgit image:

build-cgit:
  extends: .container-build
  variables:
    CONTEXT: cgit

push-cgit:
  extends: .container-push
  variables:
    CONTEXT: cgit
    IMAGE: cgit
  needs:
    - job: build-cgit
      artifacts: true

# httpd latest image:

build-httpd:
  extends: .container-build-base
  variables:
    CONTEXT: httpd/bookworm

push-httpd:
  extends: .container-push-base
  variables:
    CONTEXT: httpd/bookworm
    IMAGE: httpd
  needs:
    - job: build-httpd
      artifacts: true

# httpd bookworm image:

push-httpd-bookworm:
  extends: .container-push-base
  variables:
    CONTEXT: httpd/bookworm
    IMAGE: httpd
    TAG: bookworm
  needs:
    - job: build-httpd
      artifacts: true

# httpd bullseye image:

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

push-httpd-bullseye:
  extends: .container-push-base
  variables:
    CONTEXT: httpd/bullseye
    IMAGE: httpd
    TAG: bullseye
  needs:
    - job: build-httpd-bullseye
      artifacts: true

# httpd buster image:

build-httpd-buster:
  extends: .container-build-base
  variables:
    CONTEXT: httpd/buster

push-httpd-buster:
  extends: .container-push-base
  variables:
    CONTEXT: httpd/buster
    IMAGE: httpd
    TAG: buster
  needs:
    - job: build-httpd-buster
      artifacts: true

# sshd image:

build-sshd:
  extends: .container-build
  variables:
    CONTEXT: sshd
    DOCKER_BUILDKIT: ""

push-sshd:
  extends: .container-push
  variables:
    CONTEXT: sshd
    IMAGE: sshd
  needs:
    - job: build-sshd
      artifacts: true

# crond image:

build-crond:
  extends: .container-build-base
  variables:
    CONTEXT: crond

push-crond:
  extends: .container-push-base
  variables:
    CONTEXT: crond
    IMAGE: cron
  needs:
    - job: build-crond
      artifacts: true

# sleep image:

build-sleep:
  extends: .container-build
  variables:
    CONTEXT: sleep

push-sleep:
  extends: .container-push
  variables:
    CONTEXT: sleep
    IMAGE: sleep
  needs:
    - job: build-sleep
      artifacts: true

# webdav image:

build-webdav:
  extends: .container-build
  variables:
    CONTEXT: webdav

push-webdav:
  extends: .container-push
  variables:
    CONTEXT: webdav
    IMAGE: webdav
  needs:
    - job: build-webdav
      artifacts: true

# nginx image:

build-nginx:
  extends: .container-build-base
  variables:
    CONTEXT: nginx

push-nginx:
  extends: .container-push-base
  variables:
    CONTEXT: nginx
    IMAGE: nginx
  needs:
    - job: build-nginx
      artifacts: true

# youtube-dl image:

build-youtube-dl:
  extends: .container-build
  variables:
    CONTEXT: youtube-dl

push-youtube-dl:
  extends: .container-push
  variables:
    CONTEXT: youtube-dl
    IMAGE: youtube-dl
  needs:
    - job: build-youtube-dl
      artifacts: true

# postgres image:

build-postgres:
  extends: .container-build
  variables:
    CONTEXT: postgres

push-postgres:
  extends: .container-push
  variables:
    CONTEXT: postgres
    IMAGE: postgres
  needs:
    - job: build-postgres
      artifacts: true

# toolbx latest image:

build-toolbx:
  extends: .container-build-base
  variables:
    CONTEXT: toolbx

push-toolbx:
  extends: .container-push-base
  variables:
    CONTEXT: toolbx
    IMAGE: toolbx
  needs:
    - job: build-toolbx
      artifacts: true

# workbench image:

build-workbench:
  extends: .container-build
  variables:
    CONTEXT: workbench

push-workbench:
  extends: .container-push
  variables:
    CONTEXT: workbench
    IMAGE: workbench
  needs:
    - job: build-workbench
      artifacts: true

# megacmd image:

build-megacmd:
  extends: .container-build
  variables:
    CONTEXT: megacmd

push-megacmd:
  extends: .container-push
  variables:
    CONTEXT: megacmd
    IMAGE: megacmd
  needs:
    - job: build-megacmd
      artifacts: true

# resolver image:

build-resolver:
  extends: .container-build
  variables:
    CONTEXT: resolver

push-resolver:
  extends: .container-push
  variables:
    CONTEXT: resolver
    IMAGE: resolver
  needs:
    - job: build-resolver
      artifacts: true
