11. ● 100% portable
● Easy API for LXC
● Public Repository
● Lightweight, 1 process (ideal)
● Layers (Union File System)
○ Shares read-only data
○ Incremental
● Volumes (not layered volumes)
12. FROM ubuntu:12.04
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y gcc make g++ build-essential libc6-dev tcl wget
RUN wget http://download.redis.io/redis-stable.tar.gz -O - | tar -xvz
RUN (cd /redis-stable && make)
RUN (cd /redis-stable && make test)
RUN mkdir -p /redis-data
VOLUME ["/redis-data"]
EXPOSE 6379
ENTRYPOINT ["/redis-stable/src/redis-server"]
CMD ["--dir", "/redis-data"]
13.
14. ● Slugs
“A slug is a bundle of your source,
fetched dependencies, the language
runtime, and compiled/generated output
of the build system - ready for execution.”
16. ● Twelve Factor
“Who should read this document?
Any developer building applications which run as
a service. Ops engineers who deploy or manage
such applications.”
17. ● III - Config
“Store config in the environment
- easy to change between deploys without changing any code;
- [not] checked into the code repo accidentally;
- language- and OS-agnostic standard.”
18. ● VI - Processes
“Execute the app as one or
more stateless processes
Twelve-factor processes are stateless and share-nothing.”
19. ● IX - Disposability
“app’s processes are disposable, meaning
they can be started or stopped at a moment’s
notice”
20. ● XI - Logs
“Treat logs as event streams
… streams of all running processes and backing services”
21. “Linux for Massive Server Deployments
CoreOS enables warehouse-scale
computing on top of a minimal, modern
operating system.”
22. ● 100% distributed
● Lightweight
● cloud-init for every boot
● Automatic Updates
○ 2 boot partitions
28. “Your PaaS. Your Rules.
An open source PaaS that makes it easy to
deploy and manage applications on your
own servers. Deis builds upon Docker and
CoreOS to provide a lightweight PaaS
with a Heroku-inspired workflow.”
29. ● CoresOS + Docker + Ceph + Heroku
● Twelve-Factor
○ for Deis: must be stateless (no wordpress)
● Nginx Router + Wildcard DNS
● First release using Ceph
○ more features coming soon
● Limited
○ twelve-factor
○ only HTTP port (non-http soon)
○ must expose ONLY one port
30. ● Installation:
○ Install CoreOS and ssh keys then:
$ export DEISCTL_TUNNEL=coreos01
$ curl -sSL http://deis.io/deisctl/install.sh | sh
$ git clone https://github.com/deis/deis.git ; cd deis
$ deisctl config platform set
domain=mylocalpaas.com
$ deisctl install platform && deisctl start platform
31. Installation will set the domain in
the distributed database (Etcd)
then load and run the
“init” files (Fleet+Systemd)
into the cluster
Everything else happens by the help of twelve-factor
32.
33. ● Install client * at deis git directory
$ pip install ./client/
$ deis register http://mylocalpaas.com
$ deis keys:add
34. ● Create a
Docker App
# write some “code”
$ mkdir ~/myapp ; cd ~/myapp
$ git init
$ echo "Hello" > index.html
# create the Dockerfile
$ echo 'FROM myregistry/my-tiny-nginx
ADD ./index.html /usr/share/nginx/www/index.html
EXPOSE 80
ENTRYPOINT ["/usr/sbin/nginx"]
CMD ["-c","/etc/nginx/nginx.conf","-p","/etc/nginx","-g","daemon off;"]'
> Dockerfile
# create the app
$ git commit -a -m "initial"
$ deis create myapp
35. ● Deploy it
$ git push deis master
…
-----> Building Docker image
…
-----> Pushing image to private registry
…
-----> Launching...
done, myapp:v1 deployed to Deis
http://myapp.mylocalpaas.com
$ curl http://myapp.mylocalpaas.com
Hello
36. ● Scale it
$ deis scale cmd=5
Scaling processes... but first, coffee!
..o
done in 25s
=== myapp Processes
--- cmd:
cmd.1 up (v13)
cmd.2 up (v13)
cmd.3 up (v13)
cmd.4 up (v13)
cmd.5 up (v13)
37. ● Deploy a
Heroku App
Available Buildpacks:
● Ruby
● Nodejs
● Java
● Gradle
● Grails
● Play
● Python
● Clojure
● PHP
● Go
● Meteorite
● Perl
● Scala
● Dart
● Nginx
● Apache
38. ● Create it $ git clone https://github.com/deis/example-ruby-sinatra.git
$ cd example-ruby-sinatra
$ deis create myappheroku
Creating application... done, created myappheroku
Git remote deis added
39. ● Deploy it
(suppressed output)
$ git push deis master
-----> Ruby app detected
-----> Compiling Ruby/Rack
-----> Installing dependencies using 1.5.2
Using bundler (1.5.2)
Installing tilt (1.3.6)
Installing rack (1.5.2)
Installing rack-protection (1.5.0)
Installing sinatra (1.4.2)
Your bundle is complete!
-----> Compiled slug size is 12M
-----> Building Docker image
-----> Pushing image to private registry
-----> myappheroku deployed to Deis
http://myappheroku.mylocalpaas.com
$ curl -s http://myappheroku.mylocalpaas.com
Powered by Deis!
48. ● Advanced
Debug
Example
1 - Get the ENTRYPOINT and the CMD of your container
for buildpacks they looks like:
ENTRYPOINT [“/runner/init”]
CMD [“start”, “web”]
2 - Get (or Ask for) the address of the Deis Registry
Ex: 10.1.1.3:5000
* and if you have access to it :)
3 - Get the App’s version
$ deis releases
3 - Run it locally
$ docker run --name debug -d
10.1.1.3:5000/example-ruby-sinatra:v7
/runner/init start web
3 - Then you can do things like run “docker exec”
$ docker exec -t -i debug /bin/bash
49. ● Example:
deploy,
migrate or
reuse
your app
in another
system
using Chef/Puppet/Ansible to deploy an image from Deis
1 - Makes your automation creates a file with all
environment variables on it:
/apps/myapp/environment
export DB=user@host:port
50. ● Example:
deploy,
migrate or
reuse
your app
in another
system
using Chef/Puppet/Ansible to deploy an image from Deis
2 - Run a container from Deis:
- Use the host’s /apps/myapp directory as a
volume to /my
- Perhaps bind a local port to it
- Try to load the environment from the file
before run the ENTRYPOINT
51. ● Example:
deploy,
migrate or
reuse
your app
in another
system
using Chef/Puppet/Ansible to deploy an image from Deis
docker run -d --name myapp
-v /apps/myapp:/my
-p 80:5000
10.1.1.3:5000/myapp:v14
bash -c
‘true; source /my/environment; /runner/init start web’
52. ● Example:
deploy,
migrate or
reuse
your app
in another
system
… or
make your automation create a Dockerfile:
FROM 10.1.1.3:5000/myapp:v14
ADD /apps/myapp /my
RUN true; source /my/environment;
EXPOSE 5000
ENTRYPOINT [“/runner/init”]’
CMD [“start”,”web”]
$ sudo docker build -t myapp:v14
$ docker run -d --name myapp myapp:v14