Download - Cloud66 workshop handouts
![Page 1: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/1.jpg)
How to Deploy Web Apps with Docker containers!
Workshop Resources!
![Page 2: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/2.jpg)
hands-on lab !Part 1!
![Page 3: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/3.jpg)
Step1: !create DigitalOcean account !
!go to https://cloud.digitalocean.com/registrations/new !
and create a new account !!
Please use Promo Code: CLOUD66, to receive a $10 Credit. !
![Page 4: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/4.jpg)
Step 2: !create Cloud 66 account !
!go to https://app.cloud66.com/users/sign_up !
and create a new account !
![Page 5: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/5.jpg)
Step 3: ! create a remote
development machine !!
go to https://cloud.digitalocean.com/droplets/new!use the One-click App tab !
choose Docker 1.10.3 on 14:04choose size $40/month
region Londonpress create
you’ll get the login information mailed to you!!
![Page 6: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/6.jpg)
Step 4: ! log into development
machine !ssh to your new server
open terminal
use the password in the DigitalOcean emailyou will be asked to change your password
$ssh root@<your ip>
![Page 7: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/7.jpg)
Step 5:! install docker-compose !
output should be : docker-compose version: 1.6.2
$curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose$chmod +x /usr/local/bin/docker-compose$docker-compose —version
![Page 8: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/8.jpg)
Step 6: ! fork the bakery example
and pull the code!
go to Github.comfork https://github.com/cloud66-samples/microservices_101
create a a home-directory for the app
pull the code
$mkdir /home/app$cd /home/app
$git clone https://github.com/<your github account>/microservices_101
![Page 9: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/9.jpg)
go to the bakery/bricksandmortar folder
and change the IP address (of your new server) of the API to be used
Step 6½:! change the ip!
$vi /home/app/microservices_101/bakery/bricksandmortar/Dockerfile.development
ENV COUNTER_ADDRESS <your ip address>:8000
![Page 10: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/10.jpg)
Step 7:! build all the images!
$ cd /home/app/microservices_101/bakery
go to the bakery folder
build all the images (takes approx. 10 minutes)
$docker-compose build
![Page 11: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/11.jpg)
Step 8:! run the application!
!$docker-compose up -d
![Page 12: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/12.jpg)
Step 9: ! init the datasource with
an on/off command!
create the DB
migrate the DB schema
$docker-compose run counter rake db:create
$docker-compose run counter rake db:migrate
![Page 13: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/13.jpg)
Step 10: ! list all the running containers !
$docker ps$docker-compose ps
![Page 14: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/14.jpg)
Step 11:! play with the demo!
!check docker-compose.yml
to find out on which port the services are running !https://docs.docker.com/compose/compose-file/ !
![Page 15: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/15.jpg)
Step12:! show the log!
!see how the requests are coming in !
a great step for debugging !
$docker logs (docker ps for service names)$docker-compose logs [service_name]
![Page 16: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/16.jpg)
Step 13: ! speedup baking by scaling the minions!
!place some order in the bakery shop ;-) !
scale some minions!!!!!
see how the backing is speed up !
!
$docker-compose scale [minion_service_name]=5
![Page 17: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/17.jpg)
Step 14: ! speedup update by scaling the counter !
!$docker-compose scale counter=2
![Page 18: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/18.jpg)
Step 15: ! speedup update by scaling the counter !
!lets scale our API !
why does it fail?
$docker-compose scale counter=2
![Page 19: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/19.jpg)
Step 16: ! edit the work time of a minion
(language of choice) and build/restart!
edit the code and change the minion time You can edit on your local machine and push the changes to github and pull them into the
remote machine, or edit the code directly on the remote machine.after editing; rebuild the service
and restart the service
docker-compose will pickup the change
$docker-compose build minion_service_name
$docker-compose up -d minion_service_name
![Page 20: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/20.jpg)
Step 17: ! development of a
service !stop the service !
go to the source folder of a service !look at the docker-compose.ml !
we mount the host volume. you can edit and change code and start stop when need !!!!!
edit the service and just run only the !!!!
(no need for building) !
$docker-compose stop minion_service_name
$docker-compose run minion_service_name
![Page 21: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/21.jpg)
Step 18:! build/restart service!
done editing and debugging? build the service !!!!!
run it again!!
$docker-compose build minion_service_name
$docker-compose up -d minion_service_name
![Page 22: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/22.jpg)
Step 19:! show memory usage !
!if you want to see how the memory is getting used: !
run memory usage!!!!!!!!
$docker stats `docker ps | awk '{print $NF}' | grep -v NAMES`
![Page 23: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/23.jpg)
hands-on lab !Part 2!
![Page 24: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/24.jpg)
Step 1: ! add DO as your cloud
provider !!
go to https://app.cloud66.com/clouds and add digital ocean as the cloud provider !
![Page 25: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/25.jpg)
Step 2: ! create a new Docker
stack !go to your cloud 66 account and create a Docker stack; give the stack a name and use the service.yml in .cloud directory from
your repository!paste the service.yml in the advanced tab and hit NEXT
!
![Page 26: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/26.jpg)
Step 3: choice cloud provider (DO) and start
deploy !run on digital ocean using region: london / 20gb / 2cpu run mysql and rabbitmq on the same server !
and hit deploy
![Page 27: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/27.jpg)
Step 4: ! explore service.yml
during waiting!help.cloud66.com/building-your-stack/docker-service-
configuration !
![Page 28: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/28.jpg)
Step 5: !setup DNS!
check the UI for the new IP address of your docker cluster.!
edit your /etc/hosts file to point the following URL’s ![ip_address] www.microservices101.io![ip_address] api.microservices101.io ![ip_address] cms.microservice101.io!
!!!
![Page 29: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/29.jpg)
Step 6: !See you bakery in action !
!visit www.microservice101.io!
![Page 30: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/30.jpg)
Step 7:! use Live Logs to see the
logs of the services!
![Page 31: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/31.jpg)
Step 8: ! scale up the minion process for the UI !
![Page 32: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/32.jpg)
Step 9:! install cx!
$curl -sSL https://s3.amazonaws.com/downloads.cloud66.com/cx_installation/cx_install.sh | bash
$gcx stacks list
install out CX tool belt
go to your remote development machine (not the one created with C66)
please register the tool beltcheck if you can see your new stack
![Page 33: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/33.jpg)
scale a minion
play with scaling others and list all services:
Step 10:! scale up using CX !
$cx services scale -s [your stack] minion_bagel 5
$cx services list -s [your stack]
![Page 34: Cloud66 workshop handouts](https://reader034.vdocuments.us/reader034/viewer/2022052514/58a04cb51a28ab39648b62e1/html5/thumbnails/34.jpg)
Step 11:! change some code of the
minion and push it to your repo !
Commit your changes and push those changes to github. !Edit the service.yml to use build grid instead of pulling
images from Docker Hub.!Build and publish only that service.!