Loading .gitlab-ci.yml 0 → 100644 +38 −0 Original line number Original line Diff line number Diff line # vim: tabstop=4 shiftwidth=4 softtabstop=4 default: image: "archlinux:latest" tags: - docker before_script: - pacman -Suy --noconfirm --needed openssh docker-compose variables: DEPLOY_HOST: vz.fjfi.cvut.cz DEPLOY_USER: docker-compose-deploy stages: - deploy deploy: stage: deploy rules: - if: '"$DEPLOY_SSH_KEY" != "" && "$CI_COMMIT_REF_NAME" == "$CI_DEFAULT_BRANCH"' script: # Set up SSH - eval $(ssh-agent -s) - echo "$DEPLOY_SSH_KEY" | base64 -d | ssh-add - > /dev/null - mkdir "$HOME/.ssh" - echo "$DEPLOY_HOSTKEY" | base64 -d >> "$HOME/.ssh/known_hosts" # The native SSH support in docker/docker-compose is rather flaky: # https://github.com/docker/compose/issues/8544 # The solution is to set up the unix socket forwarding via OpenSSH: - ssh -M -S docker-ctrl-socket -fnNT -L /tmp/docker.sock:/var/run/docker.sock "$DEPLOY_USER@$DEPLOY_HOST" - export DOCKER_HOST="unix:///tmp/docker.sock" # Deploy with docker-compose on the remote host - docker-compose down --remove-orphans - docker-compose pull --quiet - docker-compose up --detach --wait # Clean up the socket forwarding - ssh -q -S docker-ctrl-socket -O exit "$DEPLOY_USER@$DEPLOY_HOST" - rm -f /tmp/docker.sock Loading
.gitlab-ci.yml 0 → 100644 +38 −0 Original line number Original line Diff line number Diff line # vim: tabstop=4 shiftwidth=4 softtabstop=4 default: image: "archlinux:latest" tags: - docker before_script: - pacman -Suy --noconfirm --needed openssh docker-compose variables: DEPLOY_HOST: vz.fjfi.cvut.cz DEPLOY_USER: docker-compose-deploy stages: - deploy deploy: stage: deploy rules: - if: '"$DEPLOY_SSH_KEY" != "" && "$CI_COMMIT_REF_NAME" == "$CI_DEFAULT_BRANCH"' script: # Set up SSH - eval $(ssh-agent -s) - echo "$DEPLOY_SSH_KEY" | base64 -d | ssh-add - > /dev/null - mkdir "$HOME/.ssh" - echo "$DEPLOY_HOSTKEY" | base64 -d >> "$HOME/.ssh/known_hosts" # The native SSH support in docker/docker-compose is rather flaky: # https://github.com/docker/compose/issues/8544 # The solution is to set up the unix socket forwarding via OpenSSH: - ssh -M -S docker-ctrl-socket -fnNT -L /tmp/docker.sock:/var/run/docker.sock "$DEPLOY_USER@$DEPLOY_HOST" - export DOCKER_HOST="unix:///tmp/docker.sock" # Deploy with docker-compose on the remote host - docker-compose down --remove-orphans - docker-compose pull --quiet - docker-compose up --detach --wait # Clean up the socket forwarding - ssh -q -S docker-ctrl-socket -O exit "$DEPLOY_USER@$DEPLOY_HOST" - rm -f /tmp/docker.sock