VSTS Docker Release step

95 Views Asked by At

I'm confused as to what is required to push my project docker container onto my production server from docker repository using VSTS.

I have done the following steps:

  1. Created my application with Dockerfile
  2. ran the build on VSTS to create a docker container
  3. Pushed that container into my hub.docker.io account.

I am manually able to log ontu my linux (ubuntu 16) box and pull the container down and run it 100%.

I would like to create a release step/action within VSTS to do that last manual step for me. Is this possible? If so can someone explain the steps or point to a good guide.

NB: The web box is my own private VPS box, no major cloud provider, just straight ubuntu with docker installed.

1

There are 1 best solutions below

6
On BEST ANSWER

You have different option now. You can use a tool like Ansible to create a script and run on your remote server.

Or you can create a script on remote server which does the whole update process

/var/myapp/update.sh

#!/bin/bash
docker pull myimage:latest
docker stop myapp
docker rm myapp
docker run -d -p 80:80 --name myapp myimage:latest

Setup a key based SSH session and then use below

ssh -i keyfile <user>@<Server> bash -c "/var/myapp/update.sh"

Edit-1

For the tty issue change the ssh command to

ssh -t -i keyfile <user>@<Server> bash -c "/var/myapp/update.sh"

For the sudo issue you can add your user to docker group

sudo usermod -aG docker <user>