2023-06-14 21:53:27 +02:00
|
|
|
stages:
|
|
|
|
- build
|
2024-09-30 22:25:44 +02:00
|
|
|
- cleanup
|
|
|
|
- publish
|
2023-06-14 21:53:27 +02:00
|
|
|
|
2024-03-12 15:49:08 +01:00
|
|
|
variables:
|
|
|
|
LATEST_IMAGE: '$CI_REGISTRY_IMAGE:latest'
|
|
|
|
PRODUCTION_URL: 'https://home.unjx.de'
|
|
|
|
|
2024-09-30 22:25:44 +02:00
|
|
|
image: docker:${V_DOCKER}-dind
|
2024-03-12 15:49:08 +01:00
|
|
|
|
|
|
|
.auth_gitlab:
|
|
|
|
before_script:
|
|
|
|
- echo $CI_REGISTRY_PASSWORD | docker login --username $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
|
|
|
|
after_script:
|
|
|
|
- docker logout
|
|
|
|
|
|
|
|
.rules:deploy:
|
|
|
|
rules:
|
2024-03-12 15:56:17 +01:00
|
|
|
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
|
2024-03-12 15:49:08 +01:00
|
|
|
|
|
|
|
build:
|
|
|
|
rules: !reference [.rules:deploy, rules]
|
|
|
|
stage: build
|
|
|
|
variables:
|
|
|
|
DOCKER_BUILDKIT: 1
|
|
|
|
CURRENT_IMAGE: '$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG'
|
|
|
|
before_script:
|
|
|
|
- !reference [.auth_gitlab, before_script]
|
|
|
|
script:
|
2024-05-31 11:31:50 +02:00
|
|
|
- docker buildx create --use
|
2024-05-31 12:02:54 +02:00
|
|
|
- >
|
2024-05-31 12:08:35 +02:00
|
|
|
docker buildx build .
|
2024-05-31 12:02:54 +02:00
|
|
|
--provenance=false
|
|
|
|
--platform=linux/amd64,linux/arm64
|
|
|
|
--build-arg APP_VERSION=${CI_COMMIT_TAG}
|
|
|
|
--build-arg V_GOLANG=${V_GOLANG}
|
|
|
|
--build-arg V_NODE=${V_NODE}
|
|
|
|
--build-arg V_ALPINE=${V_ALPINE}
|
|
|
|
--tag ${CURRENT_IMAGE}
|
|
|
|
--tag ${LATEST_IMAGE}
|
|
|
|
--push
|
2024-03-12 15:49:08 +01:00
|
|
|
after_script:
|
|
|
|
- !reference [.auth_gitlab, after_script]
|
2024-09-30 22:25:44 +02:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
rules: !reference [.rules:deploy, rules]
|
|
|
|
stage: cleanup
|
|
|
|
script:
|
|
|
|
- docker system prune -a -f
|
|
|
|
- docker volume prune -a -f
|
|
|
|
|
|
|
|
publish:
|
|
|
|
rules: !reference [.rules:deploy, rules]
|
|
|
|
stage: publish
|
|
|
|
script:
|
2024-09-30 22:44:20 +02:00
|
|
|
- mkdir -p ~/.ssh
|
2024-09-30 22:25:44 +02:00
|
|
|
- cp "$SSH_PRIVATE_KEY" ~/.ssh/bot
|
|
|
|
- chmod 600 ~/.ssh/bot
|
|
|
|
- ssh-keyscan -H ${SERVER} >> ~/.ssh/known_hosts
|
|
|
|
- ssh -i ~/.ssh/bot flohoss@${SERVER} "cd /opt/docker/home && docker compose pull && docker compose up -d"
|