2016 Microsoft Azure 雲的萬物論研討會.Jenkins + Docker @azure Container...
Preview:
Citation preview
- 1. Jenkins + Docker @Azure Container Service
- 2. SPOOKY trunk.studio/website trunk.studio/blog
trunk.studio/facebook
- 3. DevOps
- 4. CI / CD
- 5. Docker On Azure
- 6. Jenkins Use Docker
- 7. Docker Run Jenkins Jenkins Use Docker
- 8. Create Docker Machine On Azure ~ docker-machine create -h
Usage: docker-machine create [OPTIONS] [arg...]
- 9. Create Docker Machine driver azure Required:
--azure-subscription-id: Your Azure Subscription ID. Optional:
--azure-size: Size for Azure Virtual Machine. [?] docker-machine
create--driver azure--azure-size
Standard_A1_v2--azure-subscription-id XXXXXazure-docker
- 10. Azure Subscription Id
- 11. docker-machine create--driver azure--azure-size
Standard_A1_v2--azure-subscription-id XXXXXazure-docker Running
pre-create checks... (azure-docker) Completed machine pre-create
checks. Creating machine... (azure-docker) Querying existing
resource group. name="docker-machine" (azure-docker) Resource group
"docker-machine" already exists. (azure-docker) Configuring
availability set. name="docker-machine" (azure-docker) Configuring
network security group. name="azure-docker-firewall"
location="westus" (azure-docker) Querying if virtual network
already exists. name="docker-machine-vnet" location="westus"
(azure-docker) Creating virtual network. name="docker-machine-vnet"
location="westus" (azure-docker) Configuring subnet.
name="docker-machine" vnet="docker-machine-vnet"
cidr="192.168.0.0/16" (azure-docker) Creating public IP address.
static=false name="azure-docker-ip" (azure-docker) Creating network
interface. name="azure-docker-nic" (azure-docker) Creating storage
account. name= location="westus" (azure-docker) Creating virtual
machine. location="westus" size="Standard_A1_v2"
username="docker-user"
osImage="canonical:UbuntuServer:16.04.0-LTS:latest"
name="azure-docker" Waiting for machine to be running, this may
take a few minutes... Detecting operating system of created
instance... Waiting for SSH to be available... Detecting the
provisioner... Provisioning with ubuntu(systemd)... Installing
Docker...
- 12. Resources
- 13. Active Docker Machine
- 14. List Docker Machine NAME ACTIVE DRIVER STATE URL
azure-docker - azure Running tcp://104.42.230.152:2376 ~
docker-machine ls
- 15. Active Docker Machine export DOCKER_TLS_VERIFY="1" export
DOCKER_HOST= export DOCKER_CERT_PATH= export
DOCKER_MACHINE_NAME="azure-docker" # Run this command to configure
your shell: # eval $(docker-machine env azure-docker) ~ eval
$(docker-machine env azure-docker) ~ docker-machine ls ~
docker-machine env azure-docker NAME ACTIVE DRIVER STATE URL
azure-docker * azure Running tcp://104.42.230.152:2376
- 16. Docker Run Jenkins With Docker
- 17. ~ docker run--name
jenkins-dind--privileged--detach--restart always--publish
8080:8080--publish 5900:5900--publish 5001:5001--volume
/home/docker-user/jenkins:/var/lib/jenkinsagileworks/jenkins-dind
nameContainer privilegedroot detach restart alwaysContainer
- 18. ~ docker run--name
jenkins-dind--privileged--detach--restart always--publish
8080:8080--publish 5900:5900--publish 5001:5001--volume
/home/docker-user/jenkins:/var/lib/jenkinsagileworks/jenkins-dind
publish 8080 Jenkins publish 5900 VNC publish 5001 Website volume
Jenkins Home
- 19. ~ docker run--name
jenkins-dind--privileged--detach--restart always--publish
8080:8080--publish 5900:5900--publish 5001:5001--volume
/home/docker-user/jenkins:/var/lib/jenkinsagileworks/jenkins-dind
Docker Jenkins Jenkins Docker
https://github.com/smlsunxie/docker-jenkins-dind
- 20. Setting Azure Static IP
- 21. Setting Azure Firewall
- 22. Check Docker Version
- 23. Scenario
- 24. Demo
- 25. Debug With VNC ~ open vnc://104.42.230.152:5900
- 26. Dev & Prod Environment Dockerle
- 27. Development / Test FROM mhart/alpine-node:5.12.0 RUN apk
add --update git RUN apk add --update build-base libffi-dev ruby
ruby-dev&& gem install sass compass --no-ri
--no-rdoc&& apk del build-base libffi-dev
ruby-dev&& rm -rf /var/cache/apk/* RUN apk add --no-cache
make gcc g++ python && rm -rf /var/cache/apk/* FROM
agileworks/sails_sample_env COPY ./ /sailsSample WORKDIR
/sailsSample EXPOSE 5011 CMD /bin/sh -l -c 'npm start --production'
Production
- 28. Continuous Integration Flow Jenkinsle
- 29. stage('build'){ sh "docker build -t
agileworks/sails_sample_env dockers/node" sh "docker-compose run
--rm build" } stage('test'){ sh "docker-compose run --rm
--service-ports --name debug test" sh "docker-compose run -d --rm
--service-ports --name dev dev" try{ def url =
'http://localhost:5001/' input message: "Does staging at $url look
good? ", ok: "ok! build production image." }finally{ sh "docker rm
-f dev" } } stage('production'){ sh "docker build -t
agileworks/sails_sample_prod ." try{ sh "docker rm -f
sails_sample_prod" } catch(e) {} sh "docker run -d --name
sails_sample_prod -p 8800:5011 --restart always
agileworks/sails_sample_prod" } UAT
- 30. stage('build'){ sh "docker build -t
agileworks/sails_sample_env dockers/node" sh "docker-compose run
--rm build" } stage('test'){ sh "docker-compose run --rm
--service-ports --name debug test" sh "docker-compose run -d --rm
--service-ports --name dev dev" try{ def url =
'http://localhost:5001/' input message: "Does staging at $url look
good? ", ok: "ok! build production image." }finally{ sh "docker rm
-f dev" } } stage('production'){ sh "docker build -t
agileworks/sails_sample_prod ." try{ sh "docker rm -f
sails_sample_prod" } catch(e) {} sh "docker run -d --name
sails_sample_prod -p 8800:5011 --restart always
agileworks/sails_sample_prod" } UAT
- 31. test: container_name: debug image:
agileworks/sails_sample_env command: "npm run test-e2e-docker"
expose: - "1338" ports: - "5001:5001" working_dir: /sailsSample
volumes: - ./:/sailsSample depends_on: - "e2e-env" module.exports =
{ port: 4444, host: "e2e-env", browser: 'firefox', screenshotPath:
'/app/test/e2e/report/', webdriverio: { baseUrl:
'http://debug:1338', waitforTimeout: 5000, }, }; e2e-env:
container_name: e2e-env image: selenium/standalone-firefox-debug
expose: - "4444" ports: - 5900:5900" VNC Preview docker-compose.yml
chimp cong webDriver API test
- 32. browser.windowHandleSize({width:1280,height:900}).url('/');
browser.click('#login'); browser.setValue('#identifier', 'admin')
browser.setValue('#password', 'admin')
browser.click('#submit-button');
browser.element('#logout-link').state.should.be.equal('success');
#identifier #password #submit-button #login
- 33.
- 34. Azure docker-machine Docker Azure Docker Jenkins Docker CI
Docker