dader
dader

Reputation: 97

Possible to use Docker machine with continuous integration tools?

What I'm trying to do: use a continuous integration tool like CircleCI or GitLab to deploy to a DigitalOcean droplet. Locally I'm able to use Docker Machine to run something like

$ eval $(docker-machine env my-droplet)

to connect to an already created droplet and then docker run foo.

Is it possible to do such an action via the traditional deploy.yml file? Assume that I have a digitalocean-access-token and a droplet already created.

Upvotes: 1

Views: 125

Answers (2)

Boynux
Boynux

Reputation: 6222

If I understood your question correctly you can use this command to achieve what you want:

docker-machine create \ --driver generic \ --generic-ip-address=<your vm IP> \ --generic-ssh-key ~/.ssh/id_rsa \ my-droplet

And then you can do as you want:

$ eval $(docker-machine env my-droplet)

This will register the machine. Otherwise you have to provide all certs and configs from your dev env to your CI which is not secure and recommended.

Upvotes: 0

VonC
VonC

Reputation: 1324977

The integration proposed by DigitalOcean is more with Docker Cloud, meaning your CI should push your image to Docker Cloud, for DigitalOcean to use in a Droplet.

See "Deploy Horizon Using Docker Cloud & DigitalOcean" from Chris Asche

log into Docker Cloud and link your DigitalOcean account. To do this, click on 'Cloud Settings' at the bottom left. You should now see a list of Cloud Providers on the page. Click on the plug icon next to DigitalOcean to link your accounts. Note that, at the time of writing, there is a $20 credit added to your DigitalOcean account when linked with Docker Cloud.

https://raw.githubusercontent.com/pluralsight/guides/master/images/d0ffee77-f47c-41ac-942d-3d02f8b3d42f.png

Once your accounts are linked, create a new DigitalOcean Node Cluster. I'm going to call mine, horizon-with-docker in the region Toronto 1.

https://raw.githubusercontent.com/pluralsight/guides/master/images/82fcfbc6-5e4c-4038-8ce4-152c54bbf711.png

The newly created node cluster can be used to run a stack. A stack is a collection of services and each service is a collection of containers. Stacks are created with the stack-yaml file.

https://raw.githubusercontent.com/pluralsight/guides/master/images/9109de97-3698-4f44-9d10-15b7e5e6970d.png

Once created, revisit the node cluster created earlier to grab the IP address of your DigitalOcean droplet - my droplet IP is 159.203.61.66. Go ahead and visit your freshly deployed Horizon application at the IP address.

Upvotes: 0

Related Questions