ci: split dev image publishing by registry

This commit is contained in:
3252a8
2026-06-06 23:44:24 +03:00
parent 724e936660
commit 3c82f43c84
3 changed files with 62 additions and 6 deletions
+9 -5
View File
@@ -2,11 +2,11 @@ name: Docker build & push (reusable)
# Reusable workflow that builds the three image targets defined in # Reusable workflow that builds the three image targets defined in
# deploy/docker/Dockerfile (backend, worker, frontend) and optionally pushes # deploy/docker/Dockerfile (backend, worker, frontend) and optionally pushes
# them to both ghcr.io and Docker Hub under the 3252a8/ namespace. # them to the selected registries under the 3252a8/ namespace.
# #
# Called by: # Called by:
# - docker-dev.yml (tag_mode: dev, push: true) on pushes to dev # - docker-dev.yml (tag_mode: dev, push: true) on pushes to dev
# - docker-release.yml (tag_mode: release, push: true) on pushes to main # - docker-release.yml (tag_mode: release, push: true) on release tags
# - ci.yml (tag_mode: dev, push: false) on pull requests # - ci.yml (tag_mode: dev, push: false) on pull requests
on: on:
@@ -20,6 +20,10 @@ on:
description: "Tagging strategy: 'dev' or 'release'" description: "Tagging strategy: 'dev' or 'release'"
type: string type: string
required: true required: true
publish_dockerhub:
description: "Include Docker Hub tags and login when pushing"
type: boolean
default: true
# No permissions block here on purpose: a reusable workflow cannot request more # No permissions block here on purpose: a reusable workflow cannot request more
# than its caller grants, so the token scope is set by each caller # than its caller grants, so the token scope is set by each caller
@@ -78,7 +82,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub - name: Log in to Docker Hub
if: inputs.push if: inputs.push && inputs.publish_dockerhub
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
@@ -89,8 +93,8 @@ jobs:
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: | images: |
3252a8/${{ matrix.image }} name=3252a8/${{ matrix.image }},enable=${{ inputs.publish_dockerhub }}
ghcr.io/3252a8/${{ matrix.image }} name=ghcr.io/3252a8/${{ matrix.image }},enable=true
tags: | tags: |
type=raw,value=dev,enable=${{ inputs.tag_mode == 'dev' }} type=raw,value=dev,enable=${{ inputs.tag_mode == 'dev' }}
type=raw,value=latest,enable=${{ inputs.tag_mode == 'release' }} type=raw,value=latest,enable=${{ inputs.tag_mode == 'release' }}
+2 -1
View File
@@ -1,7 +1,7 @@
name: Dev images name: Dev images
# On every push to the dev branch, build all three images and push them to # On every push to the dev branch, build all three images and push them to
# ghcr.io and Docker Hub tagged `dev` and `dev-<short-sha>`. # GHCR tagged `dev`. Docker Hub dev images are published by GitLab CI.
on: on:
push: push:
@@ -22,4 +22,5 @@ jobs:
with: with:
push: true push: true
tag_mode: dev tag_mode: dev
publish_dockerhub: false
secrets: inherit secrets: inherit
+51
View File
@@ -0,0 +1,51 @@
stages:
- docker
workflow:
rules:
- if: '$CI_COMMIT_BRANCH == "dev"'
- when: never
variables:
DOCKER_BUILDKIT: "1"
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
GIT_DEPTH: "0"
docker-dev:
stage: docker
image: docker:27.5.1
services:
- name: docker:27.5.1-dind
alias: docker
interruptible: true
parallel:
matrix:
- TARGET: backend
IMAGE: remnawave-minishop-backend
- TARGET: worker
IMAGE: remnawave-minishop-worker
- TARGET: frontend
IMAGE: remnawave-minishop-frontend
before_script:
- apk add --no-cache git
- test -n "$DOCKERHUB_USERNAME"
- test -n "$DOCKERHUB_TOKEN"
- echo "$DOCKERHUB_TOKEN" | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
- docker buildx create --name gitlab-builder --use
script:
- git fetch origin dev --tags
- |
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/dev)" ]; then
echo "A newer dev commit exists; skipping Docker Hub build for $IMAGE."
exit 0
fi
- docker buildx build --load --platform linux/amd64 --file deploy/docker/Dockerfile --target "$TARGET" --build-arg "CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME" --tag "3252a8/$IMAGE:dev" .
- git fetch origin dev --tags
- |
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/dev)" ]; then
echo "A newer dev commit exists; skipping Docker Hub push for $IMAGE."
exit 0
fi
- docker push "3252a8/$IMAGE:dev"