From 8bc3dbe58b56196d714f1d666b2b7e2bc8f66cc5 Mon Sep 17 00:00:00 2001 From: anima Date: Fri, 28 Aug 2026 20:58:08 +0200 Subject: [PATCH] setup deploy on swarm --- .gitea/workflows/deploy.yml | 38 +++++++++++++++++++++++++++++++++++++ docker-compose.yml | 11 ++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..ac602ac --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,38 @@ +# https://docs.github.com/en/actions/reference/workflows-and-actions/variables +--- +name: deploy +on: + push: + paths: + - '*.yml' + - '*.yaml' + +env: + GIT_ASKPASS: ${{ vars.RUNNER_SCRIPT_DIR }}/askpass_helper.sh + GIT_TOKEN: ${{ secrets.TOKEN_SVC_CI }} + GIT_REPO: ${{ gitea.repository }} + DOCKER_STACK_NAME: aoc + +jobs: + deploy: + runs-on: swarm-test + steps: + - name: get repo + working-directory: /swarm + if: ${{ contains( gitea.event.head_commit.message , '!clone' ) }} + run: | + git clone $GITHUB_SERVER_URL/$GIT_REPO $DOCKER_STACK_NAME + cd + git submodule update --init + + - name: update repo + working-directory: /swarm/${{ env.DOCKER_STACK_NAME }} + run: git pull + + - name: stop stack + run: docker stack rm $DOCKER_STACK_NAME + + - name: start stack + working-directory: /swarm/${{ env.DOCKER_STACK_NAME }} + run: docker stack deploy -c docker-compose.yml $DOCKER_STACK_NAME + if: ${{ !contains( gitea.event.head_commit.message , '!clone' ) }} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1065464..c1a49ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,16 @@ services: aoc: - image: git.ao-it.net/aoit/aoc:latest + image: git.ao-it.net/ao-it/aoc:latest restart: always + deploy: + replicas: 1 + placement: + max_replicas_per_node: 1 + constraints: + - node.role != manager + update_config: + parallelism: 1 + delay: 10s volumes: - ./files/aoc.conf:/data/aoc.conf - ./files/aoc.db:/data/aoc.db \ No newline at end of file