Skip to content

Commit

Permalink
Blog summarizing Contributor Training on Docker Architecture (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Jun 18, 2024
1 parent 6ff8c72 commit 00b3c14
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 20 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/blog/2024/06/container-diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 19 additions & 20 deletions src/content/blog/contributor-training.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,30 @@ Live training sessions will be held weekly on Tuesdays at 8am US MT, 5pm CET or

**Past Session Recordings:**

| Training Date | Description and Recording |
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 2023-07-11 | [Testing DDEV Features, testing DDEV v1.22.0 prereleases, how to help](https://www.dropbox.com/scl/fi/8epf3vqrp6f5rf7w7up7l/20230711_contributor_training_testing_release.mp4?rlkey=s8zd82uc7a33kke9ksiqsi1yb&dl=0) |
| 2023-07-18 | [Maintaining and Improving the Docs](https://www.dropbox.com/scl/fi/2d5qryxzgwa5zat9xz056/20230718_contributor_traiing_docs.mp4?rlkey=senzp6l6j8zq52vd4y74uhqfy&dl=0) |
| 2023-07-25 | [Setting up a Go Development Environment](https://youtu.be/IjrJw0Ay-dk) see [blog](/blog/setting-up-a-go-development-environment) |
| 2023-08-08 | [Running Automated Tests Locally](https://www.dropbox.com/scl/fi/952kiwyqb60613plctr7f/2023-08-08_contributor_training_running_tests.mp4?rlkey=14t3xj6es707osboxc6c4n6a1&dl=0) |
| 2023-08-15 | [Maintain and improve ddev.com](https://www.dropbox.com/scl/fi/up13ll31115zo997kqzac/2023-08-15_contributor_training_maintain_ddev.com.mp4?rlkey=uff5jra0dp524utuigv9j6399&dl=0) see [outline](https://doc.mattstein.com/s/-BQQaSLJd) and [blog post](/blog/ddev-website-for-contributors/) |
| 2023-08-22 | [Supporting others: How can I help?](https://www.dropbox.com/scl/fi/iiu0ywf3h958wcqchykk4/2023-08-22_contributor_training_support.mp4?rlkey=ujqml1hfwbfyutwizy2jmlet9&dl=0) see [blog](https://ddev.com/blog/how-to-give-and-get-community-support/) |
| Training Date | Description and Recording |
|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 2023-07-11 | [Testing DDEV Features, testing DDEV v1.22.0 prereleases, how to help](https://www.dropbox.com/scl/fi/8epf3vqrp6f5rf7w7up7l/20230711_contributor_training_testing_release.mp4?rlkey=s8zd82uc7a33kke9ksiqsi1yb&dl=0) |
| 2023-07-18 | [Maintaining and Improving the Docs](https://www.dropbox.com/scl/fi/2d5qryxzgwa5zat9xz056/20230718_contributor_traiing_docs.mp4?rlkey=senzp6l6j8zq52vd4y74uhqfy&dl=0) |
| 2023-07-25 | [Setting up a Go Development Environment](https://youtu.be/IjrJw0Ay-dk) see [blog](/blog/setting-up-a-go-development-environment) |
| 2023-08-08 | [Running Automated Tests Locally](https://www.dropbox.com/scl/fi/952kiwyqb60613plctr7f/2023-08-08_contributor_training_running_tests.mp4?rlkey=14t3xj6es707osboxc6c4n6a1&dl=0) |
| 2023-08-15 | [Maintain and improve ddev.com](https://www.dropbox.com/scl/fi/up13ll31115zo997kqzac/2023-08-15_contributor_training_maintain_ddev.com.mp4?rlkey=uff5jra0dp524utuigv9j6399&dl=0) see [outline](https://doc.mattstein.com/s/-BQQaSLJd) and [blog post](/blog/ddev-website-for-contributors/) |
| 2023-08-22 | [Supporting others: How can I help?](https://www.dropbox.com/scl/fi/iiu0ywf3h958wcqchykk4/2023-08-22_contributor_training_support.mp4?rlkey=ujqml1hfwbfyutwizy2jmlet9&dl=0) see [blog](https://ddev.com/blog/how-to-give-and-get-community-support/) |
| 2023-08-29 | [Building and pushing an improved Docker image](https://www.dropbox.com/scl/fi/rylo13nfjqasu4fkckeiq/2023-08-29_contributor_training_building_pushing_docker_image.mp4?rlkey=ckqhocebjw8vhc80geb13x2fc&dl=0) see [outline](https://randyfay.notion.site/Building-and-pushing-DDEV-s-Docker-images-dba76bf9b5ad4c2aafe47017a13105c3?pvs=4) |
| 2023-09-05 | [Marketing: How can I help?](https://www.dropbox.com/scl/fi/5az16wfshgipi641r5ew8/2023-09-05_contributor_training_marketing.mp4?rlkey=9ykeuvy2bp90fjymva7hckqju&dl=0) |
| 2023-09-12 | [DDEV Architecture: Go, Docker Compose, Containers](https://www.dropbox.com/scl/fi/rh7o01yc4uriittvth9wp/2023-09-12_DDEV_architecture.mp4?rlkey=f44r4kyhq7flfwbcody3omcs0&dl=0), see [outline](https://randyfay.notion.site/Contributor-Training-DDEV-Architecture-72968891333c4c4b936c09cf7d1e0a80?pvs=4) |
| 2023-09-19 | [DDEV Testing Infrastructure](https://www.dropbox.com/scl/fi/tg5qfkmjcgzckx8z5i5t6/2023-09-19_Testing_Infrastructure.mp4?rlkey=cuemz2fafaltj2dtsgepld9t7&dl=0), see [outline](https://randyfay.notion.site/Contributor-Training-Testing-Infrastructure-804600e2b19d4d46903d868bc3a0701a?pvs=4) |
| 2023-09-26 | DDEV Automated Tests and How to Improve Them, Randy forgot to record! but see [outline](https://randyfay.notion.site/Contributor-Training-Automated-tests-d238854dff384fa6b640592feb04b14e?pvs=4) |
| 2023-10-31 | [Measuring and Analyzing User Data with Amplitude](https://www.dropbox.com/scl/fi/xqx3ne70y8oojypr2g2m3/2023-10-31_Amplitude_analytics.mp4?rlkey=eg8hwh0o5sog7e46pl424ntbp&dl=0) see [outline](https://randyfay.notion.site/Contributor-Training-Amplitude-Analytics-71202feb067741fca72b68c6641adc41?pvs=4) |
| 2023-11-07 | [DDEV Add-ons: Creating, maintaining, testing](https://www.dropbox.com/scl/fi/bnvlv7zswxwm8ix1s5u4t/2023-11-07_DDEV_Add-ons.mp4?rlkey=5cma8s11pscxq0skawsoqrscp&dl=0) see [outline](https://randyfay.notion.site/Contributor-Training-Add-ons-creating-maintaining-testing-1040f7d007c94bef8669a400a2437c98?pvs=4) |
| 2023-11-14 | [DDEV Hosting Providers: Creating, Maintaining, Using](https://www.dropbox.com/scl/fi/yjgdjkiwwr4egyaewj40e/2023-11-14_DDEV_provider_integrations.mp4?rlkey=4ygpjaopgp2xbdswptsnzf50u&dl=0), see [outline](https://randyfay.notion.site/Contributor-Training-Provider-integrations-fb9676ca17d64fe6bf16a6b5b1622ccb?pvs=4). |
| 2024-05-15 | [Debugging DDEV Go Code: Commands and Tests](https://www.youtube.com/watch?v=E-AEzC1p76E), see [blog](/blog/golang-debugging). |
| 2024-05-22 | [Xdebug and DDEV, How it works and Troubleshooting](https://www.youtube.com/watch?v=4MrwXTaHfnc), see [blog](/blog/xdebug-debugging). |
| 2023-09-05 | [Marketing: How can I help?](https://www.dropbox.com/scl/fi/5az16wfshgipi641r5ew8/2023-09-05_contributor_training_marketing.mp4?rlkey=9ykeuvy2bp90fjymva7hckqju&dl=0) |
| 2023-09-12 | [DDEV Architecture: Go, Docker Compose, Containers](https://www.dropbox.com/scl/fi/rh7o01yc4uriittvth9wp/2023-09-12_DDEV_architecture.mp4?rlkey=f44r4kyhq7flfwbcody3omcs0&dl=0), see [outline](https://randyfay.notion.site/Contributor-Training-DDEV-Architecture-72968891333c4c4b936c09cf7d1e0a80?pvs=4) |
| 2023-09-19 | [DDEV Testing Infrastructure](https://www.dropbox.com/scl/fi/tg5qfkmjcgzckx8z5i5t6/2023-09-19_Testing_Infrastructure.mp4?rlkey=cuemz2fafaltj2dtsgepld9t7&dl=0), see [outline](https://randyfay.notion.site/Contributor-Training-Testing-Infrastructure-804600e2b19d4d46903d868bc3a0701a?pvs=4) |
| 2023-09-26 | DDEV Automated Tests and How to Improve Them, Randy forgot to record! but see [outline](https://randyfay.notion.site/Contributor-Training-Automated-tests-d238854dff384fa6b640592feb04b14e?pvs=4) |
| 2023-10-31 | [Measuring and Analyzing User Data with Amplitude](https://www.dropbox.com/scl/fi/xqx3ne70y8oojypr2g2m3/2023-10-31_Amplitude_analytics.mp4?rlkey=eg8hwh0o5sog7e46pl424ntbp&dl=0) see [outline](https://randyfay.notion.site/Contributor-Training-Amplitude-Analytics-71202feb067741fca72b68c6641adc41?pvs=4) |
| 2023-11-07 | [DDEV Add-ons: Creating, maintaining, testing](https://www.dropbox.com/scl/fi/bnvlv7zswxwm8ix1s5u4t/2023-11-07_DDEV_Add-ons.mp4?rlkey=5cma8s11pscxq0skawsoqrscp&dl=0) see [outline](https://randyfay.notion.site/Contributor-Training-Add-ons-creating-maintaining-testing-1040f7d007c94bef8669a400a2437c98?pvs=4) |
| 2023-11-14 | [DDEV Hosting Providers: Creating, Maintaining, Using](https://www.dropbox.com/scl/fi/yjgdjkiwwr4egyaewj40e/2023-11-14_DDEV_provider_integrations.mp4?rlkey=4ygpjaopgp2xbdswptsnzf50u&dl=0), see [outline](https://randyfay.notion.site/Contributor-Training-Provider-integrations-fb9676ca17d64fe6bf16a6b5b1622ccb?pvs=4). |
| 2024-05-15 | [Debugging DDEV Go Code: Commands and Tests](https://www.youtube.com/watch?v=E-AEzC1p76E), see [blog](/blog/golang-debugging). |
| 2024-05-22 | [Xdebug and DDEV, How it works and Troubleshooting](https://www.youtube.com/watch?v=4MrwXTaHfnc), see [blog](/blog/xdebug-debugging) |
| 2024-06-04 | [DDEV Docker Architecture](/blog/ddev-docker-architecture) |

<a name="upcoming-trainings"></a>
**Upcoming Trainings:**

* DDEV Docker Architecture, including build stages
* Traefik Router Configuration and Possibilities
* Advanced DDEV Add-On Techniques
* Advanced DDEV Add-On Techniques, including automated testing and debugging tests
* DDEV automated tests and how to improve them
* Hostname Resolution and Debugging in DDEV
* Using AI in DDEV Development (Continue.dev, etc.)
Expand Down
66 changes: 66 additions & 0 deletions src/content/blog/ddev-docker-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: "Contributor Training: DDEV Docker Architecture"
pubDate: 2024-06-18
# modifiedDate: 2024-06-23
summary: DDEV's Docker Architecture
author: Randy Fay
featureImage:
src: /img/blog/2024/06/container-diagram.png
alt: DDEV Container Architecture
categories:
- Guides
---

At the simplest conceptual level, DDEV is a wrapper on Docker and `docker-compose`. Here's our [Contributor Training](contributor-training.md) explaining how we use Docker in DDEV, including the Docker images and containers and how they're related.

<iframe width="560" height="315" src="https://www.youtube.com/embed/ee1YFvATQKw?si=2Fovta2MheJJdG-T" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

## What is a Docker Image? What is a Docker Container?

The easiest way to think about a Docker image is as a recipe for a little running computer that will be running as a "container". Many containers can be built from one image. In the object-oriented world, an image might be a "class", and a container might be an "object" created from that class.

The easiest way to think about containers is as little mostly-isolated computers that run in the Docker world of a "real" computer. The Docker world has its own isolated networking and even isolated filesystems.

## How do we build Docker Images?

Docker images are built as layers, where each layer is a command in the context of the build. A Dockerfile is a set of commands like `RUN` or `ADD` that add these all together.

DDEV's Docker builds typically squash all the layers together after they're built up, to make each image mostly one huge layer, hopefully resulting in a faster download at upgrade time.

## What are the basic DDEV images and containers?

DDEV's images and containers are all in the [containers](https://github.com/ddev/ddev/tree/master/containers) directory:

* **[`ddev-webserver`](https://github.com/ddev/ddev/tree/master/containers/ddev-webserver)** which runs the web server (`nginx` or `apache`), the `php-fpm`, and `mailpit`. It's also what most people customize or use when they're using `ddev exec`. As an image, `ddev-webserver` is a child of [`ddev-php-base`](https://github.com/ddev/ddev/tree/master/containers/ddev-php-base), which is not run directly as a container.
* `ddev-webserver` is based on Debian 12 Bookworm, the current stable version of Debian. Keeping up with the latest Debian version means that we can support current technologies and packages.
* Why is `ddev-webserver` so big? It's big! Since DDEV is a tool for local developers, the goal is always to make things work well for the developer. We always try to keep the size down, but it's a balancing act. For example, the web server includes all locales, so that people all over the world in all locales can use it without alteration.
* **Customization:** Each project can [customize the web image](https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/) with `webimage_extra_packages` or `.ddev/web-build/Dockerfile.*`.
* Why aren't `nginx`, `php-fpm`, `node`, and `mailpit` in separate containers? It's fairly common for each Docker container to run a single process, so it would not be unexpected for DDEV to have separate `nginx` and `php` containers (and it once did). However, it seemed better for users at one point in DDEV's history to combine them all in one container, and they're still there. We re-evaluate this from time to time.
* **[`ddev-dbserver`](https://github.com/ddev/ddev/tree/master/containers/ddev-dbserver)** runs the MySQL, MariaDB, or PostgreSQL daemons.
* The MariaDB images are built on top of the official upstream Docker images.
* The MySQL images have to be done quite differently, because MySQL has never provided ARM64 packages. So take a minute and [fry your brain](https://ddev.readthedocs.io/en/stable/developers/release-management/#maintaining-ddev-dbserver-mysql-57-and-80-arm64-images) with what we have to do to build MySQL 5.6 and 8.x images. We do hope to use the `bitnami/mysql` upstream images in the future since they recently started supporting ARM64.
* The PostgreSQL images are simpler.

* **[`ddev-router'](https://github.com/ddev/ddev/tree/master/containers/ddev-traefik-router)** is in charge of receiving HTTP requests and directing them to the right container in the right project. Because of the router, many projects can be running at one time and can be using the same ports, but the router will distribute requests correctly to them.
* The current standard router is based on [Traefik Proxy](https://traefik.io/traefik/), a widely adopted, well-documented reverse proxy.
* It's possible to do [extensive modifications](https://ddev.readthedocs.io/en/stable/users/extend/traefik-router/#traefik-configuration) to the Traefik router.
* You can add environment variables or other overrides to a `~/.ddev/router-compose.*.yaml`.
* The now-deprecated `nginx-proxy` router is still available, but will be removed in DDEV v1.24.

## Project-level customizations of the main images

Every project's `ddev-webserver` and `ddev-dbserver` get at least some customizations for the project and the user, even if you don't use `webimage_extra_packages` or a `.ddev/web-build/Dockerfile.*`. For example, a Linux user with the same name and user ID is built into the image, composer is updated, and `corepack` is enabled if configured to be enabled.

And of course additional Debian packages can be added easily with `webimage_extra_packages` and more extensive configuration can be done with `.ddev/web-build/Dockerfile.*`. You can even add [`pecl` extensions](https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#pecl-php-extensions-not-supported-by-debsuryorg) or anything else that you could add to a Debian system.

## Maintaining and updating DDEV Docker images

DDEV's images are built-in standard ways with a full `make` and Dockerfile setup. They can be built locally for experimentation, but normally we push them with a [standardized GitHub Actions workflow](https://ddev.readthedocs.io/en/stable/developers/release-management/#pushing-docker-images-with-the-github-actions-workflow)

If you build your own `ddev-webserver` for example, you can build it with local changes using `cd containers/ddev-webserver && make VERSION=someversion` and then update the [versionconstants.go webtag](https://github.com/ddev/ddev/blob/master/pkg/versionconstants/versionconstants.go#L14) to refer to `someversion`.

## Contributions welcome!

Your suggestions to improve this blog are welcome. You can do a PR to this blog adding your techniques. Info and a training session on how to do a PR to anything in ddev.com is at [DDEV Website For Contributors](ddev-website-for-contributors.md).

And join us for the next [DDEV Live Contributor Training](contributor-training.md). Sign up at [DDEV Live Events Meetup](https://www.meetup.com/ddev-events/events/).

0 comments on commit 00b3c14

Please sign in to comment.