Add new build pipeline

This commit is contained in:
Alessio Davoli 2023-07-10 17:17:18 +02:00
parent e6ba387dc1
commit 7fdb4d9c88

View file

@ -1,17 +1,26 @@
pipeline: pipeline:
build: build_and_deploy:
image: alpine:3.14 image: alpine:3.14
secrets: [docker_password, docker_username] secrets: [docker_password, docker_username, runner_private_key]
commands: commands:
# Install deps - apk add --no-cache openssh docker docker-compose jq
- apk add docker docker-compose jq ################### Provisioning
# Log into docker registry
- echo "$${DOCKER_PASSWORD}" | docker login --password-stdin --username "$${DOCKER_USERNAME}" git.webdeploy.it - echo "$${DOCKER_PASSWORD}" | docker login --password-stdin --username "$${DOCKER_USERNAME}" git.webdeploy.it
- echo "TAG=$(jq -r .version ./package.json)" >> .env - echo "TAG=$(jq -r .version ./package.json)" >> .env
# Build image - echo "ORIGIN=https://pianello.webdeploy.it" >> .env
- docker-compose -f docker-compose.build.yml build - docker-compose -f docker-compose.build.yml build
- docker push git.webdeploy.it/pianello/pianello-web-app:latest - docker push git.webdeploy.it/pianello/frontend:latest
- docker push git.webdeploy.it/pianello/pianello-web-app:$(jq -r .version ./package.json) - docker push git.webdeploy.it/pianello/frontend:$(jq -r .version ./package.json)
# DEPLOY STUFF
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- printf "%s" "$${RUNNER_PRIVATE_KEY}" > ~/.ssh/id_ed25519
- chmod 600 ~/.ssh/id_ed25519
- ssh-add ~/.ssh/id_ed25519
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- cat .env | ssh theater@prev.theater.webdeploy.it -p 11122 "cat - > .env" # copy env
- cat docker-compose.prod.yml | ssh theater@prev.theater.webdeploy.it -p 11122 "cat - > docker-compose.yml && docker compose pull && docker compose stop && docker compose up -d --remove-orphans" # start docker compose
volumes: volumes:
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock