Docker ‐ from development to production in minutes (PoSobota #91)

Docker ‐ from development to production in minutes (PoSobota #91)

1633975316e340c5f24414567a3f3679?s=128

Vladimír Kriška

October 28, 2017
Tweet

Transcript

  1. Docker ‐ From development to produc on in minutes Vladimír

    Kriška @ujovlado
  2. $ whoami Brogrammer Developer at Keboola building ETL platform Keboola

    Connection Occasional blogger medium.com/@ujovlado Rekurzia - custom dev trainings twitter.com/ujovlado 2
  3. Docker ‐ Development 3

  4. How to start project in Ne e? mkdir project cd

    project composer create-project nette/web-project . requirements: PHP, Composer & other libraries installed locally 4
  5. Move to Docker ... Prepare Docker le: FROM php:7.1-apache ENV

    COMPOSER_ALLOW_SUPERUSER=1 RUN apt-get update -q \ && apt-get install unzip git \ wget --no-install-recommends -y COPY composer.sh composer.sh RUN ./composer.sh \ && rm composer.sh \ && mv composer.phar /usr/local/bin/composer ... 5
  6. 6

  7. Prepare docker-compose.yml le: 7

  8. Start development docker-compose run --rm --service-ports app or docker-compose up

    app For CLI usage and tests override command : docker-compose run --rm app bash 8
  9. Demo I. 9

  10. Docker ‐ Produc on 10

  11. Few ps before start Use some service to run containers

    eg. ECS, Docker Cloud, ... Use same image for development and production Don't mount code to containers in production If you need logs, send them from container Don't run databases in containers until you know what you're doing (you may loose all your data) Automate in small steps, not everything at once 11
  12. Build and image docker-compose build app Building app Step 1/12

    : FROM php:7.1-apache ... ... Step 11/12 : RUN composer install --prefer-dist --no-dev ---> Using cache ---> 9dddd2ab7071 Step 12/12 : RUN chmod -R 777 log temp ---> Using cache ---> f390380986e5 Successfully built f390380986e5 Successfully tagged ujovlado/posobota-91-docker:latest 12
  13. Push the image docker login docker push ujovlado/posobota-91-docker:latest repository: docker.io/ujovlado/posobota-91-docker

    alternatives: Quay, AWS ECR, ... 13
  14. Setup ECS 1. Create load balancer (I will use existing)

    2. Create new task de nition 3. Create a service 4. Check/modify target group 5. Setup DNS (already done) 6. Make changes 7. Redeploy the service 8. Automate 14
  15. Demo II. 15

  16. Thank you. Ques ons? 16