Deploying on Digital Ocean
- Sign up at Digital Ocean and get an API Token
- Note - you can also access droplet via console w/in Digital Ocean
- https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
- users: root/pw=address, doug/pw=social, dougwells/pw=social
- https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
- Note - you can also access droplet via console w/in Digital Ocean
- Provision a VM in Digital Ocean
- $ docker-machine create --driver digitalocean --digitalocean-access-token <API-Token-AlphaNum> <desired-name-of-VM-on-Digital-Ocean>
- (Actual Code w/o Token) $ docker-machine create --driver digitalocean --digitalocean-access-token abcFakexyz docker-app-machine
- --driver
- Docker has drivers for all of the large cloud providers (DO, AWS, Azure, Linode, etc).
- --digitalocean
- Each provider has their own way of sharing API Token
- Name of VM (we use docker-app-machine)
- --driver
- Set up Docker Client to communicate with docker-machine/server on Digital Ocean
- When we finished provisioning VM on DO (above), got the following message:
- > To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: $ docker-machine env docker-app-machine
- > # Run this command to configure your shell: $ eval $(docker-machine env docker-app-machine)
- Do exactly that. Steps 1 & 2. Run env command (sets environment var)
- Run $ docker-machine ls to see all VM and to make sure DO is active (*)
- Run $ docker info to display info on Dig Ocean VM
- When we finished provisioning VM on DO (above), got the following message:
- Let Digital Ocean know how to get app image (that it will run to spin up containers)
- Image that passed CircleCI is on Docker Hub. How point DO to Docker Hub?
- Copy docker-compose.yml into new file called prod.yml
- In prod.yml
- Copy docker-compose.yml into new file called prod.yml
- Image that passed CircleCI is on Docker Hub. How point DO to Docker Hub?
- Sign up at Digital Ocean and get an API Token
change line build: .
Builds new image w Dockerfile in CWD
to → image: dougwells/dockerapp
Use existing image from Docker Hub
- Time to Deploy our dockerapp!!
- Make sure docker VM is active → $ docker-machine ls
- If not, follow steps in section C above
- With docker vm active
- $ docker-compose -f prod.yml up -d
- docker-compose up → regular command that builds/gets images and spins them up
- -f prod.yml → what file to use (otherwise defaults to docker-compose.yml)
- -d → free up console (“detached” mode)
- $ docker-compose -f prod.yml up -d
- Now when run $ docker-machine ls
- → get name of app (docker-app-machine) w/IP
- Name we gave VM in first step above (step “b” - when we provisioned VM on DO)
- → get name of app (docker-app-machine) w/IP
- Make sure docker VM is active → $ docker-machine ls
- Digital Ocean has lots of options for provisioning a VM
- Google “docker digital ocean driver”
- High level summary of steps
- Create Servers
- Time to Deploy our dockerapp!!
$ docker-machine create --driver digitalocean --digitalocean-access-token <API-Token-AlphaNum> <desired-name-of-VM-on-Digital-Ocean>
- “Provision” Servers
- Once the server has been set up, it needs to be "provisioned", meaning that the all software and configuration settings are being applied. Other tools beside Docker include Chef, Puppet and Ansible for this.
- “Provision” Servers
$ docker-compose -f prod.yml up -d
- To take to Swarm, need tool like Consul (see below)