Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

GDGSCL - Docker a jeho provoz v Heroku a AWS

2,152 views

Published on

Example Simple NodeJS Application for Docker demo
- https://gist.github.com/abtris/6aca9b2668b8b5af0208
Video
- https://www.youtube.com/watch?v=p6olO6NChno&feature=youtu.be

Published in: Software, Technology
  • Login to see the comments

GDGSCL - Docker a jeho provoz v Heroku a AWS

  1. 1. Docker Build, Ship and Run GDG Spaghetti Code Liberec, 6.10.2015 1
  2. 2. Ladislav Prskavec 4 Twitter: @abtris 4 Blog: http://blog.prskavec.net 4 Site Reliability Engineer (SRE) in Apiary.io GDG Spaghetti Code Liberec, 6.10.2015 2
  3. 3. GDG Spaghetti Code Liberec, 6.10.2015 3
  4. 4. What's Docker? GDG Spaghetti Code Liberec, 6.10.2015 4
  5. 5. Analogy from logistics GDG Spaghetti Code Liberec, 6.10.2015 5
  6. 6. Goods, wares GDG Spaghetti Code Liberec, 6.10.2015 6
  7. 7. Containers GDG Spaghetti Code Liberec, 6.10.2015 7
  8. 8. Why Docker? GDG Spaghetti Code Liberec, 6.10.2015 8
  9. 9. Fast and scalableGDG Spaghetti Code Liberec, 6.10.2015 9
  10. 10. Build once, run anywhere GDG Spaghetti Code Liberec, 6.10.2015 10
  11. 11. Configure once, run anywhere GDG Spaghetti Code Liberec, 6.10.2015 11
  12. 12. Example of using Docker 4 build documentation in Sphinx with latex support 4 executing code in many different programming languages without requiring a single compiler or script interpreter on your machine - docker exec 4 running gui app in docker at linux GDG Spaghetti Code Liberec, 6.10.2015 12
  13. 13. Example of using Docker 4 development without install ing many tools at local machine 4 Vagrant, Otto dev 4 continues integration using docker 4 Jenkins, TravisCI, CircleCI 4 DevOps platform for build, deploy and manage apps across any cloud - Tutum GDG Spaghetti Code Liberec, 6.10.2015 13
  14. 14. Docker Engine GDG Spaghetti Code Liberec, 6.10.2015 14
  15. 15. Docker Engine GDG Spaghetti Code Liberec, 6.10.2015 15
  16. 16. VM vs Docker GDG Spaghetti Code Liberec, 6.10.2015 16
  17. 17. Containers and images docker run hello-world GDG Spaghetti Code Liberec, 6.10.2015 17
  18. 18. Docker Remote API 4 client & server in Docker 4 docker ps 4 docker build 4 docker push/pull 4 docker run/stop 4 docker inspect GDG Spaghetti Code Liberec, 6.10.2015 18
  19. 19. Docker lifecycle 4 a build produces an immutable image 4 a container is as instance of the image GDG Spaghetti Code Liberec, 6.10.2015 19
  20. 20. Docker lifecycle GDG Spaghetti Code Liberec, 6.10.2015 20
  21. 21. Container lifecycle GDG Spaghetti Code Liberec, 6.10.2015 21
  22. 22. Dockerfile # Firefox over VNC # # VERSION 0.3 FROM ubuntu # Install vnc, xvfb in order to create a 'fake' display and firefox RUN apt-get update && apt-get install -y x11vnc xvfb firefox RUN mkdir ~/.vnc # Setup a password RUN x11vnc -storepasswd 1234 ~/.vnc/passwd # Autostart firefox (might not be the best way, but it does the trick) RUN bash -c 'echo "firefox" >> /.bashrc' EXPOSE 5900 CMD ["x11vnc", "-forever", "-usepw", "-create"] GDG Spaghetti Code Liberec, 6.10.2015 22
  23. 23. DockerHub GDG Spaghetti Code Liberec, 6.10.2015 23
  24. 24. GDG Spaghetti Code Liberec, 6.10.2015 24
  25. 25. Docker tools GDG Spaghetti Code Liberec, 6.10.2015 25
  26. 26. Docker compose 4 defining and running multi-container applications with Docker GDG Spaghetti Code Liberec, 6.10.2015 26
  27. 27. docker-compose.yml web: build: . ports: - "5000:5000" volumes: - .:/code links: - redis redis: image: redis GDG Spaghetti Code Liberec, 6.10.2015 27
  28. 28. Docker machine 4 Machine lets you create Docker hosts on your computer, on cloud providers, and inside your own data center. 4 part of Docker toolbox 4 replacement for boot2docker GDG Spaghetti Code Liberec, 6.10.2015 28
  29. 29. Demo GDG Spaghetti Code Liberec, 6.10.2015 29
  30. 30. Docker swarm 4 Docker Swarm is native clustering for Docker. GDG Spaghetti Code Liberec, 6.10.2015 30
  31. 31. Kinematic 4 desktop GUI for Docker 4 Mac and Windows only GDG Spaghetti Code Liberec, 6.10.2015 31
  32. 32. Docker Trusted Registry (DTR) 4 private dedicated image registry GDG Spaghetti Code Liberec, 6.10.2015 32
  33. 33. Yours private registry 4 storage at S3 docker run -d -p 5000:5000 --restart=always --name registry registry:2 GDG Spaghetti Code Liberec, 6.10.2015 33
  34. 34. Open Container ekosystem 1 1 https://www.mindmeister.com/389671722/open-container-ecosystem- formerly-docker-ecosystem GDG Spaghetti Code Liberec, 6.10.2015 34
  35. 35. GDG Spaghetti Code Liberec, 6.10.2015 35
  36. 36. Docker at Heroku heroku plugins:install heroku-docker 4 https://gist.github.com/abtris/ 6aca9b2668b8b5af0208 4 app.json must contain: { image: heroku/nodejs } 4 app.json specification GDG Spaghetti Code Liberec, 6.10.2015 36
  37. 37. Dockerfile - heroku/nodejs # Inherit from Heroku's stack FROM heroku/cedar:14 # Internally, we arbitrarily use port 3000 ENV PORT 3000 # Which version of node? ENV NODE_ENGINE 0.12.2 # Locate our binaries ENV PATH /app/heroku/node/bin/:/app/user/node_modules/.bin:$PATH # Create some needed directories RUN mkdir -p /app/heroku/node /app/.profile.d WORKDIR /app/user # Install node RUN curl -s https://s3pository.heroku.com/node/v$NODE_ENGINE/node-v$NODE_ENGINE-linux-x64.tar.gz | tar --strip-components=1 -xz -C /app/heroku/node # Export the node path in .profile.d RUN echo "export PATH="/app/heroku/node/bin:/app/user/node_modules/.bin:$PATH"" > /app/.profile.d/nodejs.sh ONBUILD ADD package.json /app/user/ ONBUILD RUN /app/heroku/node/bin/npm install ONBUILD ADD . /app/user/ GDG Spaghetti Code Liberec, 6.10.2015 37
  38. 38. Create Dockerfile heroku docker:init $ cat Dockerfile FROM heroku/nodejs GDG Spaghetti Code Liberec, 6.10.2015 38
  39. 39. Docker compose web: build: . command: 'bash -c ''node index.js''' working_dir: /app/user environment: PORT: 8080 ports: - '8080:8080' shell: build: . command: bash working_dir: /app/user environment: PORT: 8080 ports: - '8080:8080' volumes: - '.:/app/user' GDG Spaghetti Code Liberec, 6.10.2015 39
  40. 40. Start development environment $ docker-compose up web Building web... ... $ curl "http://$(docker-machine ip dev):8080" GDG Spaghetti Code Liberec, 6.10.2015 40
  41. 41. Rebuild containers Changes to your app and config. docker-compose build GDG Spaghetti Code Liberec, 6.10.2015 41
  42. 42. Heroku Release $ heroku create ... $ heroku docker:release ... $ heroku open GDG Spaghetti Code Liberec, 6.10.2015 42
  43. 43. Demo GDG Spaghetti Code Liberec, 6.10.2015 43
  44. 44. AWS Release $ docker build -t abtris/docker-liberec-example-app ... $ docker push abtris/docker-liberec-example-app ... $ docker pull abtris/docker-liberec-example-app ... GDG Spaghetti Code Liberec, 6.10.2015 44
  45. 45. Run on AWS $ docker run -d -p 3000:3000 abtris/docker-liberec-example-app node index.js $ curl http://localhost:3000 GDG Spaghetti Code Liberec, 6.10.2015 45
  46. 46. Demo GDG Spaghetti Code Liberec, 6.10.2015 46
  47. 47. Docker & AWS 4 Elastic Beanstalk 4 EC2 Container Service (ECS) 4 EC2 with Swarm, Mesos or Kubernetes GDG Spaghetti Code Liberec, 6.10.2015 47
  48. 48. Questions? GDG Spaghetti Code Liberec, 6.10.2015 48
  49. 49. Credits 4 boat-containers.jpg 2 4 computer-scrap.jpg [^3] 4 vm-vs-docker.png [^4] 4 docker logos [^5] 4 formule_one.jpg [^6] 2 https://www.flickr.com/photos/41864721@N00/3451530961/ [^3]: https://www.flickr.com/photos/7362086@N02/2019666131/ [^4]: http://www.jayway.com/wp-content/uploads/2015/03/vm-vs-docker.png [^5]: https://www.docker.com/brand-guidelines GDG Spaghetti Code Liberec, 6.10.2015 49

×