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. Docker ‐ From development to
    produc on in minutes
    Vladimír Kriška
    @ujovlado

    View full-size slide

  2. $ whoami
    Brogrammer
    Developer at Keboola
    building ETL platform Keboola Connection
    Occasional blogger medium.com/@ujovlado
    Rekurzia - custom dev trainings
    twitter.com/ujovlado
    2

    View full-size slide

  3. Docker ‐ Development
    3

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  6. Prepare docker-compose.yml le:
    7

    View full-size slide

  7. 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

    View full-size slide

  8. Docker ‐ Produc on
    10

    View full-size slide

  9. 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

    View full-size slide

  10. 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

    View full-size slide

  11. Push the image
    docker login
    docker push ujovlado/posobota-91-docker:latest
    repository: docker.io/ujovlado/posobota-91-docker
    alternatives: Quay, AWS ECR, ...
    13

    View full-size slide

  12. 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

    View full-size slide

  13. Thank you.
    Ques ons?
    16

    View full-size slide