From 1ab112438b1a00f7701c464a5fd2960de7d184db Mon Sep 17 00:00:00 2001 From: Vlad Durnea Date: Mon, 30 Mar 2026 11:47:19 +0300 Subject: [PATCH] Switch CI/CD to Gitea Actions and Gitea registry --- {.github => .gitea}/workflows/ci.yml | 0 .gitea/workflows/images.yml | 40 ++++++++++++++++++++++++++++ DOCKER.md | 19 +++++++++++++ Makefile | 10 +++++++ docker/scripts/build_images.sh | 22 +++++++++------ docker/scripts/push_images.sh | 40 ++++++++++++++++++++++++++++ swarm/stacks/control-plane.yml | 4 +-- swarm/stacks/platform.yml | 10 +++---- 8 files changed, 130 insertions(+), 15 deletions(-) rename {.github => .gitea}/workflows/ci.yml (100%) create mode 100644 .gitea/workflows/images.yml create mode 100644 docker/scripts/push_images.sh diff --git a/.github/workflows/ci.yml b/.gitea/workflows/ci.yml similarity index 100% rename from .github/workflows/ci.yml rename to .gitea/workflows/ci.yml diff --git a/.gitea/workflows/images.yml b/.gitea/workflows/images.yml new file mode 100644 index 0000000..eeda4d4 --- /dev/null +++ b/.gitea/workflows/images.yml @@ -0,0 +1,40 @@ +name: images + +on: + push: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + + - name: Login to Gitea Container Registry + env: + REGISTRY: ${{ secrets.GITEA_REGISTRY_HOST }} + USERNAME: ${{ secrets.GITEA_REGISTRY_USERNAME }} + TOKEN: ${{ secrets.GITEA_REGISTRY_TOKEN }} + run: | + test -n "$REGISTRY" + test -n "$USERNAME" + test -n "$TOKEN" + echo "$TOKEN" | docker login "$REGISTRY" -u "$USERNAME" --password-stdin + + - name: Build images + env: + IMAGE_PREFIX: ${{ secrets.GITEA_IMAGE_PREFIX }} + IMAGE_TAG: ${{ github.sha }} + run: | + test -n "$IMAGE_PREFIX" + sh docker/scripts/build_images.sh all + + - name: Push images + env: + IMAGE_PREFIX: ${{ secrets.GITEA_IMAGE_PREFIX }} + IMAGE_TAG: ${{ github.sha }} + run: | + test -n "$IMAGE_PREFIX" + sh docker/scripts/push_images.sh all diff --git a/DOCKER.md b/DOCKER.md index 2351aed..83ad3c0 100644 --- a/DOCKER.md +++ b/DOCKER.md @@ -33,6 +33,23 @@ Build images: sh docker/scripts/build_images.sh all ``` +Build images for the Gitea container registry: + +```bash +export IMAGE_PREFIX=git.madapes.com/madapes/cloudlysis +export IMAGE_TAG=dev +sh docker/scripts/build_images.sh all +``` + +Push images to the Gitea container registry: + +```bash +docker login git.madapes.com +export IMAGE_PREFIX=git.madapes.com/madapes/cloudlysis +export IMAGE_TAG=dev +sh docker/scripts/push_images.sh all +``` + Create dev secrets required by the observability stack: ```bash @@ -42,6 +59,8 @@ sh docker/scripts/swarm_dev_secrets.sh Deploy: ```bash +export IMAGE_PREFIX=cloudlysis +export IMAGE_TAG=dev docker stack deploy -c swarm/stacks/platform.yml cloudlysis docker stack deploy -c swarm/stacks/control-plane.yml cloudlysis_control docker stack deploy -c swarm/stacks/observability.yml cloudlysis_obs diff --git a/Makefile b/Makefile index ca49b42..6ed7fb5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ .PHONY: docker-build-platform docker-build-control docker-build-observability docker-build-all +.PHONY: docker-push-platform docker-push-control docker-push-all .PHONY: compose-up compose-down compose-ps compose-up-observability compose-down-observability .PHONY: swarm-dev-secrets swarm-deploy-platform swarm-deploy-control swarm-deploy-observability swarm-deploy-all .PHONY: swarm-rm-platform swarm-rm-control swarm-rm-observability swarm-rm-all @@ -15,6 +16,15 @@ docker-build-observability: docker-build-all: sh docker/scripts/build_images.sh all +docker-push-platform: + sh docker/scripts/push_images.sh platform + +docker-push-control: + sh docker/scripts/push_images.sh control + +docker-push-all: + sh docker/scripts/push_images.sh all + compose-up: docker compose up -d --build diff --git a/docker/scripts/build_images.sh b/docker/scripts/build_images.sh index e785a05..2b93874 100644 --- a/docker/scripts/build_images.sh +++ b/docker/scripts/build_images.sh @@ -4,9 +4,12 @@ set -eu mode="${1:-all}" build_rust() { - image="$1" + service="$1" package="$2" bin="$3" + prefix="${IMAGE_PREFIX:-cloudlysis}" + tag="${IMAGE_TAG:-dev}" + image="${prefix}/${service}:${tag}" docker build \ -f docker/Dockerfile.rust \ --build-arg PACKAGE="$package" \ @@ -18,20 +21,23 @@ build_rust() { } build_ui() { - image="$1" + service="$1" + prefix="${IMAGE_PREFIX:-cloudlysis}" + tag="${IMAGE_TAG:-dev}" + image="${prefix}/${service}:${tag}" docker build -f docker/Dockerfile.ui -t "$image" . } build_platform() { - build_rust cloudlysis/gateway:dev gateway gateway - build_rust cloudlysis/aggregate:dev aggregate aggregate - build_rust cloudlysis/projection:dev projection projection - build_rust cloudlysis/runner:dev runner runner + build_rust gateway gateway gateway + build_rust aggregate aggregate aggregate + build_rust projection projection projection + build_rust runner runner runner } build_control() { - build_rust cloudlysis/control-api:dev api api - build_ui cloudlysis/control-ui:dev + build_rust control-api api api + build_ui control-ui } case "$mode" in diff --git a/docker/scripts/push_images.sh b/docker/scripts/push_images.sh new file mode 100644 index 0000000..e317199 --- /dev/null +++ b/docker/scripts/push_images.sh @@ -0,0 +1,40 @@ +#!/bin/sh +set -eu + +mode="${1:-all}" + +push_image() { + service="$1" + prefix="${IMAGE_PREFIX:-cloudlysis}" + tag="${IMAGE_TAG:-dev}" + docker push "${prefix}/${service}:${tag}" +} + +push_platform() { + push_image gateway + push_image aggregate + push_image projection + push_image runner +} + +push_control() { + push_image control-api + push_image control-ui +} + +case "$mode" in + platform) + push_platform + ;; + control) + push_control + ;; + all) + push_platform + push_control + ;; + *) + echo "usage: sh docker/scripts/push_images.sh [platform|control|all]" 1>&2 + exit 2 + ;; +esac diff --git a/swarm/stacks/control-plane.yml b/swarm/stacks/control-plane.yml index cd6a43a..a988aad 100644 --- a/swarm/stacks/control-plane.yml +++ b/swarm/stacks/control-plane.yml @@ -2,7 +2,7 @@ version: "3.9" services: control-api: - image: cloudlysis/control-api:dev + image: ${IMAGE_PREFIX:-cloudlysis}/control-api:${IMAGE_TAG:-dev} environment: CONTROL_API_ADDR: "0.0.0.0:8080" CONTROL_PLACEMENT_PATH: "/etc/control/placement.json" @@ -26,7 +26,7 @@ services: condition: on-failure control-ui: - image: cloudlysis/control-ui:dev + image: ${IMAGE_PREFIX:-cloudlysis}/control-ui:${IMAGE_TAG:-dev} environment: VITE_CONTROL_API_URL: "http://control-api:8080" networks: diff --git a/swarm/stacks/platform.yml b/swarm/stacks/platform.yml index 1fe1ffe..f362f69 100644 --- a/swarm/stacks/platform.yml +++ b/swarm/stacks/platform.yml @@ -13,7 +13,7 @@ services: replicas: 1 gateway: - image: cloudlysis/gateway:dev + image: ${IMAGE_PREFIX:-cloudlysis}/gateway:${IMAGE_TAG:-dev} environment: GATEWAY_ADDR: 0.0.0.0:8080 GATEWAY_GRPC_ADDR: 0.0.0.0:8081 @@ -37,7 +37,7 @@ services: order: stop-first aggregate: - image: cloudlysis/aggregate:dev + image: ${IMAGE_PREFIX:-cloudlysis}/aggregate:${IMAGE_TAG:-dev} environment: AGGREGATE_NATS_URL: nats://nats:4222 AGGREGATE_STORAGE_PATH: /data @@ -54,7 +54,7 @@ services: condition: on-failure projection: - image: cloudlysis/projection:dev + image: ${IMAGE_PREFIX:-cloudlysis}/projection:${IMAGE_TAG:-dev} environment: PROJECTION_NATS_URL: nats://nats:4222 PROJECTION_STREAM_NAME: AGGREGATE_EVENTS @@ -81,7 +81,7 @@ services: failure_action: rollback runner_saga: - image: cloudlysis/runner:dev + image: ${IMAGE_PREFIX:-cloudlysis}/runner:${IMAGE_TAG:-dev} environment: RUNNER_NATS_URL: nats://nats:4222 RUNNER_MODE: saga @@ -100,7 +100,7 @@ services: replicas: 1 runner_effect: - image: cloudlysis/runner:dev + image: ${IMAGE_PREFIX:-cloudlysis}/runner:${IMAGE_TAG:-dev} environment: RUNNER_NATS_URL: nats://nats:4222 RUNNER_MODE: effect