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

Kickass Development Environments with Docker (P...

Kickass Development Environments with Docker (PHPBenelux 2019)

David McKay

January 26, 2019
Tweet

More Decks by David McKay

Other Decks in Technology

Transcript

  1. @rawkode David McKay ◍ Developer Advocate at InfluxData ◍ Docker

    / CI / CD ◍ DevOps / SaltStack ◍ Event-Driven Systems ◍ CQRS / ES ◍ Elixir, Go, and Rust
  2. My Development Environment Circa 2000 $ tree awesome-million-pound-project └── src

    ├── game.php ├── game.php.bk-david ├── game.php.bk-deano ├── main.php ├── main.php.maybe-fixed ├── main.php.bk-1999-12-02 ├── main.php.bk-1999-12-02.2 ├── player.php ├── player.php.orig └── .swp.player.php
  3. My Development Production Environment Circa 2000 $ tree awesome-million-pound-project └──

    src ├── game.php ├── game.php.bk-david ├── game.php.bk-deano ├── main.php ├── main.php.maybe-fixed ├── main.php.bk-1999-12-02 ├── main.php.bk-1999-12-02.2 ├── player.php ├── player.php.orig └── .swp.player.php
  4. “ Docker allows you to package an application with all

    of its dependencies into a standardized unit for software development.
  5. Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍

    Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
  6. (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  7. (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  8. (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  9. (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  10. (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  11. ENTRYPOINT and CMD Explained in 17 seconds ... CMD [“echo”,

    “Hello”] in a Dockerfile docker run my-image == $ Hello
  12. ENTRYPOINT and CMD Explained in 13 seconds ... CMD [“echo”,

    “Hello”] in a Dockerfile docker run my-image echo Goodbye == $ Goodbye
  13. ENTRYPOINT and CMD Explained in 10 seconds ... ENTRYPOINT [“echo”]

    CMD [“Hello”] in a Dockerfile docker run my-image == $ Hello
  14. ENTRYPOINT and CMD Explained in 7 seconds ... ENTRYPOINT [“echo”]

    CMD [“Hello”] in a Dockerfile docker run --entrypoint=”echo” my-image Woop! == $ Woop!
  15. ENTRYPOINT and CMD Explained in 4 seconds ... ENTRYPOINT [“echo”]

    CMD [“Hello”] in a Dockerfile docker run --entrypoint=”echo” my-image == $
  16. Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍

    Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
  17. Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍

    Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
  18. docker-compose.yml version: “3” services: php: image: php:7 … database: image:

    mariadb:latest environment: MYSQL_USERNAME: rawkode MYSQL_PASSWORD: *******
  19. docker-compose.yml version: “3” services: php: image: php:7 … database: image:

    mariadb:latest environment: MYSQL_USERNAME: rawkode MYSQL_PASSWORD: *******
  20. Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍

    Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
  21. Tips: Mindful of Network Collisions Every new docker-compose file is,

    potentially, a new docker network / bridge on your host. Eventually, you’ll get a collision docker-compose down
  22. Tips: Alpine Linux Unless you need Ubuntu / Fedora, use

    Alpine Linux Ubuntu -- 130MB Alpine -- 3.99MB
  23. Tips: Keep a Single Dockerfile Using MultiStage Builds, you can

    usually keep your project to a single Dockerfile FROM node AS node RUN npm install FROM php COPY --from=node assets