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

Symfony and Docker: a refreshing new experience

Symfony and Docker: a refreshing new experience

Recently, new configurators for Docker and Docker Compose have been added to Symfony Flex.
This means that Symfony can now transparently add the services and PHP extensions needed by your preferred packages!

You want to use Doctrine ORM? So you need a database and the related PDO extension! We’ve got you covered.
You use the mailer? So you want MailCatcher in your development environment? Let’s do this.
You want Panther? so you need Chrome and ChromeDriver! No problem!

But there is more: we now offer you Docker skeletons that take advantage of these new capabilities, and that you can use locally, but also in your CI system and in production!

E66449b8260b07a1cf51c5ab5eaa8180?s=128

Kévin Dunglas

December 10, 2021
Tweet

Transcript

  1. Symfony & Docker A new pattern to build fast and

    reliable web APIs A refreshing new development experience
  2. Kévin Dunglas ➔ Co-founder of Les-Tilleuls.coop ➔ Symfony Core Team

    ➔ Symfony Docker ➔ API Platform @dunglas
  3. API, cloud, PHP and JS experts ➔ Scop, 100% employee-owned

    ✊ ➔ Democratically managed 💬 ➔ 55 people 🦄 ➔ France, Tunisia, Morocco 🌎 ➔ contact@les-tilleuls.coop 💌 Les-Tilleuls.coop
  4. Docker?!

  5. ➔ An OS-level virtualization platform • Build: Dockerfile • Share:

    Registry (hub) • Run: Engine ➔ Software is packaged in containers • Embedded binaries, libs, config files... • Run in isolation • Share a single OS kernel: ⬆performance Docker
  6. Why should you use Docker? ➔ Easy onboarding • docker-compose

    up • No more cumbersome and outdated README files ➔ Versioned, same software and configs everywhere: git pull • locally, for the entire team • CI • staging • prod ➔ Standardized, industry standard ➔ Great tooling, large ecosystem (GitHub Actions, Rancher, K8s...) ➔ (Almost) cross platform: Linux, Windows, Mac @dunglas
  7. Dockerfile

  8. ➔ Define and run multi-container apps ➔ In dev, staging

    and even prod (single host) ➔ Example for a Symfony app: • PHP container • Web server container • DBMS container • Cache server container • … Docker Compose
  9. Docker Compose

  10. Docker and Symfony: an Old Story

  11. 7 years ago @ Sensiolabs I’ve been introduced to a

    brand new tool for hipsters during a workshop led by Jérémy Derussé at Sensiolabs.
  12. 6 years ago @ Les-Tilleuls.coop Vincent Chalamon proposed a patch

    adding Docker support to API Platform.
  13. 4 years ago I started the “Symfony Docker” installer and

    project skeleton (co-maintained by Maxime Helias).
  14. 2 years ago I contributed experimental Flex configurators for Docker

    and Docker Compose.
  15. Today @ SymfonyWorld 2021 ➔ I’m very happy to announce

    the immediate availability of the official Symfony Docker integration @dunglas
  16. Symfony Flex

  17. Symfony Flex ➔ Composer plugin ➔ Generates the configuration of

    newly installed PHP packages ➔ New: Docker support • Dockerfile: add PHP extensions, libs, binaries • Docker Compose: adds new services @dunglas
  18. Docker Compose Flex Configurator

  19. Supported Packages Package Image symfony/orm-pack postgres symfony/mercure-bundle dunglas/mercure symfony/panther n/a

    (Dockerfile only) symfony/mailer schickling/mailcatcher blackfireio/blackfire-symfony-meta blackfire/blackfire More to come: PRs welcome! github.com/symfony/recipes
  20. Symfony CLI

  21. Symfony CLI ➔ Create new Symfony applications ➔ Deploy in

    SymfonyCloud ➔ Local web server, built-in TLS support ➔ Integration with Docker Compose ➔ Dev environments only ➔ Require local installations of PHP and Symfony CLI @dunglas
  22. Symfony CLI: Docker Compose Support

  23. Symfony CLI: Docker Compose Support

  24. Symfony Docker Skeleton

  25. Symfony Docker ➔ Docker-based skeleton and installer ➔ Prod ready

    ➔ Compatible with the Flex configurators ➔ No local dependencies, you just need Docker ➔ No bloat, readable config: only 2 containers • PHP • Web server ➔ Automatic TLS certificate generation and renewal ➔ Native support for Mercure and Vulcain @dunglas
  26. GitHub Template (optional)

  27. Get Started

  28. Deploy in prod (single host)

  29. Dockerfile Flex Configurator Support

  30. docker-compose exec php \ composer req orm

  31. ➔ Free and Open Source web server ➔ Secure and

    super fast, written in Go ➔ Extensible ➔ Native PHP FPM support 😍 ➔ Automatic HTTPS, even for localhost ➔ HTTP/3! ➔ Mercure, Vulcain, OAuth, OIDC modules ➔ Cloud native (API, hot config reloading…) Caddy Inside
  32. Kubernetes

  33. ➔ Free and Open Source container orchestration system ➔ Unlike

    Docker Compose: native cluster support ➔ Allows to scale deployments (with autoscaling support) ➔ Industry standard ➔ Managed clusters offered by AWS, GCP, Azure, DO, OVH, Scaleway… ➔ Battery included, but complex Kubernetes
  34. ➔ The Kubernetes package manager ➔ Like apt but, for

    Kubernetes ➔ Charts: packages for Kubernetes ➔ Graphical tools (Lens IDE, Ahoy) ➔ Templates for Kubernetes YAML manifests Helm
  35. Symfony & Kubernetes ➔ Images provided by Symfony Docker are

    compatible with Kubernetes ➔ Images provided by API Platform are compatible too ➔ API Platform provides a ready-made Helm chart that you can use with Symfony Docker too! ➔ Just copy it and run helm install @dunglas
  36. ➔ Any questions? Thank you!