ラズパイ2で動く docker paas

Download ラズパイ2で動く Docker PaaS

Post on 16-Apr-2017

3.081 views

Category:

Engineering

3 download

Embed Size (px)

TRANSCRIPT

Title

2 Docker PaaSTetsuhiro Sato

tetzSDNhttp://network-programmability.connpass.com/

2

TL;DR Docker PaaS PaaS CI 3

Linux Linux git scale web=3git push master

4$ wget http://raw.github.com/tetsusat/raspaas/master/bootstrap.sh $ chmod +x bootstrap.sh$ sudo ./bootstrap.sh

Docker PaaS

5Docker PaaSPaaSOSOSDocker PaaS PaaS PaaS Docker PaaS Docker

Docker PaaSx86 Docker PaaS (>_ $1/Dockerfile

# generate docker-compose.ymlCMD=$(get_procfile_cmd $1/Procfile)APP=$(get_app_name $1)cat $1/docker-compose.ymlweb: image: $2/$APP command: $CMD ports: - 5000EOFcompileDockerfile detect Gemfile docker-compose.yml CMD Procfile : 5000

compile Dockerfile

18FROM ruby:2.2.2

ENV PORT 5000 EXPOSE 5000

RUN mkdir /app WORKDIR /app ONBUILD ADD ./Gemfile Gemfile ONBUILD ADD ./Gemfile.lock Gemfile.lock ONBUILD RUN bundle install

ONBUILD ADD . /appFROM raspaas/ruby:2.2.2 compile Dockerfileraspaas/ruby:2.2.2 compile FROM Dockerfile Dockerfile Automated Build https://hub.docker.com/r/raspaas/ARM Buildpack-like (>_ $HOME/.ssh/ssh-config - ssh-keygen -f $HOME/.ssh/id_rsa -t rsa -q -N '' - sshpass -p $$VAGRANT_HOST_PASS ssh-copy-id $$VAGRANT_HOST_USER@$$VAGRANT_HOST - echo 'vagrant-host ansible_ssh_host=$$VAGRANT_HOST ansible_ssh_user=$$VAGRANT_HOST_USER' > hosts - echo 'vagrant-guest ansible_ssh_port=22222 ansible_ssh_host=$$VAGRANT_HOST ansible_ssh_user=$$VAGRANT_USER' >> hosts - ansible-playbook -i hosts playbooks/vagrant-up.yml - sshpass -p vagrant ssh-copy-id 'vagrant@$$VAGRANT_HOST -p 22222' - ansible-playbook -i hosts playbooks/raspaas-setup.yml - ansible-playbook -i hosts playbooks/app-setup.yml - cd tests - rspec spec/raspaas_app_spec.rb - ansible-playbook -i ../hosts ../playbooks/app-auto-scale.yml - rspec spec/raspaas_auto_scale_spec.rb - ansible-playbook -i ../hosts ../playbooks/vagrant-destroy.yml

AnsibleAnsible Playbook Infrataster

Ansible PlaybooksRaspaas 28- hosts: vagrant-guest tasks: - name: restart docker engine command: sudo service docker restart - name: download bootstrap.sh command: wget http://raw.github.com/tetsusat/raspaas/master/bootstrap.sh - name: chmod +x bootstrap.sh command: chmod +x bootstrap.sh - name: start bootstrap script command: sudo ./bootstrap.sh terokuplaybooks/raspaas-setup.yml

Ansible Playbooks App 29- hosts: vagrant-guest tasks: - name: change ssh config for git push shell: echo 'StrictHostKeyChecking no' > $HOME/.ssh/config - name: git clone command: git clone https://github.com/tetsusat/ruby-sample.git - name: teroku create command: teroku create args: chdir: ruby-sample/ - name: git push command: git push teroku master args: chdir: ruby-sample/playbooks/app-setup.yml

Infrastater Spec App 30require 'spec_helper'

describe server(:vagrant_host) do describe http('http://:8080/ruby-sample') do it "responds content including 'Hello, world'" do expect(response.body).to include('Hello, world') end endendtests/spec/raspaas_app_spec.rb

Infrastater Spec 31require 'spec_helper'

seen = []

describe server(:vagrant_host) do 3.times do describe http('http://:8080/ruby-sample') do it "responds content including 'Hello, world' from unseen container" do see = "" if response.body =~ /Hello, world from (\w+)/ see = $1 end expect(seen).not_to include(see) seen

Recommended

View more >