Docker Image with alpine linux for deploy with ssh in gitlab ci
Supported tags and respective Dockerfile links
- latest (Dockerfile)
- Create a new SSH key pair locally with ssh-keygen
- Copy the public key to the servers you want to have access to (usually in
~/.ssh/authorized_keys
). - Create a new secret variable. As Key enter the name SSH_PRIVATE_KEY and in the Value field paste the content of your private key that you created earlier.
- Create a new secret variable. As Key enter the name SSH_HOST and in the Value field paste the IP or domain of the server.
- Create a new secret variable. As Key enter the name SSH_USER and in the Value field paste the user ssh.
- Add a deploy stage en your
.gitlab-ci.yml
. For example:
production:
image: lgatica/gitlab-deploy-ssh
stage: deploy
script:
- ssh $SSH_USER@$SSH_HOST 'docker pull your-image:latest'
- ssh $SSH_USER@$SSH_HOST 'docker-compose up -d your-app'
environment: production
only:
- master