Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

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

Vladimír Kriška

October 28, 2017
Tweet

More Decks by Vladimír Kriška

Other Decks in Programming

Transcript

  1. $ whoami Brogrammer Developer at Keboola building ETL platform Keboola

    Connection Occasional blogger medium.com/@ujovlado Rekurzia - custom dev trainings twitter.com/ujovlado 2
  2. 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
  3. 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
  4. 6

  5. 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
  6. 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
  7. 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
  8. 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