Kickass Development Environments with Docker (PHPBenelux 2019)

Kickass Development Environments with Docker (PHPBenelux 2019)

69172dc4e4cc3e4cdd234c40adf395fa?s=128

David McKay

January 26, 2019
Tweet

Transcript

  1. 3.

    @rawkode David McKay ◍ Developer Advocate at InfluxData ◍ Docker

    / CI / CD ◍ DevOps / SaltStack ◍ Event-Driven Systems ◍ CQRS / ES ◍ Elixir, Go, and Rust
  2. 5.

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

    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. 8.
  5. 9.
  6. 12.
  7. 15.
  8. 16.

    “ Docker allows you to package an application with all

    of its dependencies into a standardized unit for software development.
  9. 17.

    Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍

    Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
  10. 19.

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

    (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  12. 21.

    (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  13. 22.

    (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  14. 23.

    (Simplified) Dockerfile for PHP FROM ubuntu:17.04 RUN apt install -y

    php-cli COPY hello.php /code WORKDIR /code ENTRYPOINT [“php”] CMD [“-v”]
  15. 24.
  16. 26.

    ENTRYPOINT and CMD Explained in 17 seconds ... CMD [“echo”,

    “Hello”] in a Dockerfile docker run my-image == $ Hello
  17. 27.

    ENTRYPOINT and CMD Explained in 13 seconds ... CMD [“echo”,

    “Hello”] in a Dockerfile docker run my-image echo Goodbye == $ Goodbye
  18. 28.

    ENTRYPOINT and CMD Explained in 10 seconds ... ENTRYPOINT [“echo”]

    CMD [“Hello”] in a Dockerfile docker run my-image == $ Hello
  19. 29.

    ENTRYPOINT and CMD Explained in 7 seconds ... ENTRYPOINT [“echo”]

    CMD [“Hello”] in a Dockerfile docker run --entrypoint=”echo” my-image Woop! == $ Woop!
  20. 30.

    ENTRYPOINT and CMD Explained in 4 seconds ... ENTRYPOINT [“echo”]

    CMD [“Hello”] in a Dockerfile docker run --entrypoint=”echo” my-image == $
  21. 31.
  22. 32.

    Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍

    Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
  23. 34.
  24. 35.

    Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍

    Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
  25. 42.

    docker-compose.yml version: “3” services: php: image: php:7 … database: image:

    mariadb:latest environment: MYSQL_USERNAME: rawkode MYSQL_PASSWORD: *******
  26. 43.

    docker-compose.yml version: “3” services: php: image: php:7 … database: image:

    mariadb:latest environment: MYSQL_USERNAME: rawkode MYSQL_PASSWORD: *******
  27. 45.
  28. 46.

    Docker ◍ Image Builder ◍ Virtualisation ◍ Image Delivery ◍

    Orchestration (Dev) ➔ docker build ➔ docker run ➔ docker push / pull ➔ docker-compose
  29. 49.

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

    Tips: Alpine Linux Unless you need Ubuntu / Fedora, use

    Alpine Linux Ubuntu -- 130MB Alpine -- 3.99MB
  31. 53.

    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