An introduction to DDev and how extend it with a mix of techs / Web Tools / Joshua Stuart Graham
Watch on YouTubeVideo summary
The video introduces DDev as the official local development tool recommended by the Drupal community for running isolated project environments. The speaker explains that a primary purpose of such tools is to prevent code changes made locally from breaking shared production sites or affecting other developers' work, ensuring stability during the testing phase. While acknowledging existing alternatives like Lando, the presentation highlights DDev's monolithic architecture which bundles multiple utilities and PHP versions within its containers for ease of use. A significant advantage discussed is the tool's ability to map any port internally without being restricted to specific ports, along with a robust plugin system that allows users to version control custom layouts applied as overlays on top of default configurations.
Despite these strengths, the speaker notes several limitations and "gotchas" inherent in DDev's opinionated architecture. Users cannot completely remove or override core components like the web container without adhering to specific rules, which can be restrictive if one wishes to run entirely different technologies such as Java containers alongside standard setups. The configuration structure differs from tools that keep everything in a single root YAML file; instead, DDev utilizes a layered approach with separate folders for build versions and runtime settings. Additionally, while the tool supports various databases like MySQL and PostgreSQL out of the box, customizing SSL certificates to work behind corporate proxies or Zscaler requires specific Dockerfile modifications to inject trusted root certificates early in the container lifecycle.
To address performance and workflow efficiency, DDev incorporates Mutagen for Linux and WSL users, which synchronizes file changes between the host machine and containers with minimal latency, offering up to ten times faster editing speeds compared to traditional volume mounting methods. The tool also features built-in database snapshot capabilities that allow for binary backups during migrations rather than relying on slow SQL dumps, as well as a unique "DDev Share" feature that tunnels local sites over the internet using specialized domains without requiring complex DNS configuration from visitors. Custom commands can be defined and executed either within containers or directly on the host system via specific flags, providing flexibility for running scripts like `htop` or other utilities not included in the default image.
In conclusion, while DDev offers high reliability, extensive community support, and seamless integration with text editors through plugins, it trades some of the raw flexibility found in more generic development tools like Vagrant. The speaker emphasizes that if a project requires strict adherence to predefined structures or needs to run outside standard web container paradigms, other solutions might be preferable; however, for most Drupal-centric workflows where stability and ease of maintenance are priorities, DDev stands out as an excellent choice. Its ability to handle complex scenarios like custom SSL requirements and efficient file synchronization makes it a powerful solution that balances opinionated design with the necessary extensibility required by modern development teams.
Read the full video transcript
Cool. Okay, thanks everyone for coming.
Um, yeah, so I apologize for the
taskbar. Um,
maybe we'll try and work that out next
time.
Uh, but uh yeah, my presentation is
about the D Dev uh development tool, um,
uh which is the uh the tool
uh the official tool that is recommended
by the Drupal community to run your um
local development site. Um, and uh I
thought there was like a knowledge gap
um
in how to use it uh
in in Australia. So, I thought I should
do a presentation about like uh kind of
a little bit about what it is and how to
how to what's good and what's bad and a
few configuration kind of options.
Okay, cool. Um,
yeah, we'll just a short spiel about
myself.
Um, 10 years Drupal.
Um, I do some running and stuff and I
can't last the marathons, but I
enthusiasm.
It's great. Okay, that's that's the
agenda there you can see on the screen.
Um, but yeah, it's basically uh yeah, a
little bit about it, pros and cons, um
compared to like Lando, so like
flexibility and things.
Um, what you might need to worry like uh
it um
uh you might have like corporate policy
uh restriction on your computer, so you
might need to worry about uh SSL
certificates. Um, and so that the
container can like update to the right
PHP version.
Uh, and there's a few other
customizations uh that you can do. Um,
and a note about like performance as
well.
Uh there's a QR code. The QR code uh
I'll update the presentation. It's the
to my um
GitHub. Um,
you can like bookmark it and then I'll
upload it uh later after this. I was
just like fixing some formatting
um
for the presentation. So, unfortunately,
it's uh it's not there yet, but it will
be there. So, um hoping that this
presentation is going to be kind of like
a a reference guide uh for some quick uh
options you might use.
Okay.
So, let me tell you about what local
development is.
So,
the way
So, one way to think of it is like we
cannot all like work on the same thing.
We cannot all work on the same car, the
same
paint or something. So, when you like
you do your code, you know, if you break
it for
the website to to something, then you
break it for everyone else. So, you need
a local development tool.
So, you have your copy of the code and
you can do what you want with it and
then when it's ready,
you can
put that new change in with everyone
else's tested changes.
We're sending that.
So, good. Cool.
Um
Done.
Cool. Yeah. So, comparing DDEV to to
Lando and others. So, the pros and cons.
DDEV uses a kind of monolithic
monolithic
a mono repo kind of architecture
where it has multiple versions and lots
of utilities included in the container.
So, you download all the content like
when you turn on your project
and you can switch between different
installed versions of PHP. So, it's a
bit easier.
Um
but there's some gotchas when you try
and deviate outside of the
this kind of architecture, I guess. Like
a different Apache
configuration with your PHP is kind of
like fiddly.
But, for what it does, it's excellent.
Very reliable.
Um
Yep. And so, one one cool thing about it
is that you
the traffic proxy inside it, the router,
can map any port to any port inside it.
You're not locked into just AC ports.
So, that's kind of
very nice.
Um and
also it's a bit more um, to me, based on
my research, it's very fast. Uh,
like more
uh, maintain a more community uh,
velocity in its development compared to
to DDEV uh, to to Lando.
Um
Yep. Cool. Uh, bit more specifics about
it. Um
uh, DDEV has a kind of very
um
focused uh, architecture. So, one um
uh, some things to note is you
uh, it has
when you run your project, you have like
different types of projects. Um, you
might uh, DDEV cannot can run not just
Drupal, but also um
like a WordPress uh, or like a Laravel
or something like that as well. Um
And so, it has a all these projects has
a con- kind of defined uh, way of
running. And that's like a web uh,
container and a database container.
And a few other things. And uh, you in
the default like in in this
uh
the way that it runs is you cannot
delete you cannot remove you cannot like
override the web container, but you can
modify the web container, but you cannot
like remove it completely. So, you can't
like take some parts of DDEV and then
reuse it. You have to like kind of work
with this in the
uh, the rules of
uh,
it's opinionated architecture and then
add things on top and then it works
great. Uh, so, there's some notes if
you're trying to run something like
completely different like a Java
container or something, you then that's
great, but you have to have
the web container as well. So, you might
have to like proxy your request across.
So, it's a little bit opinionated in
that uh, area. Um
the the way it works with the uh,
configuration and the kind of
uh
layers to its settings. Um, in your
project folder you have a DDEV uh
.ddev folder in your project folder.
Um
and uh, compared to Lando, whereas kind
of more like everything's in the YAML
file in the project root, and DDEV is uh
in the folder, and things are split up
like layers and things. And when it
runs, it will like compile them into
uh kind of mono- monolithic uh files,
and then it Docker will run off those.
So, it's kind of like a split up um
compared to Lando. Uh so, it's a bit
easier for like layers, but a bit harder
for the replacement.
Um
the
uh
DDEV has a strong plugin uh
architecture um and community. So, it's
um you can kind of have like create your
own plugins, and you can version control
them.
Um and it seems like to me Lando's
like it does have plugin system, but
it's not really apparent how you can
make your own version um or upgrade like
like version like go to certain versions
of them.
Um and the plugins, I'll talk later on
this, but the plugin is not just like,
"Oh, we'll just add like this type of
container or something." It's more like
a layout, and then it applies that
layout to your project. So, you got like
a overlay of different files.
Um and it uh uh
updates as fast when the
uh plugin is updated, unless this uh
automatic um
automatic generated line is there, then
it will not update that file cuz it
knows that you've manually overwritten
it.
So, that is kind of nice. It's kind of
like best of both worlds, I guess. But
you do need to track like if you don't
override it, then is there some change
upstream that you might need to worry
about?
That then that's kind of
a uh a con, I guess.
Um a bit more, it's got more support.
DDEV has more support currently like
Lando and other things. It's got more
provider support. Um it's uh also has
um some performance enhancements. Also
has like DDEV Share. Uh Lando used to
have DDEV Share, but the provider that
used
uh it
uh they stopped doing that. Um but DDEV
uh uses a different provider, DDEV
Share. So, that's where you can Maybe
you're showing your local website
uh to someone and they have a mobile
phone and instead of like trying to work
out how to host file like DNS overrides
on their phone, you just DDEV Share. It
will uh show your local website um on
the internet
through a tunnel, so some specialized
like unique domain, and then you can
share your website. So, it's very useful
uh for that.
Um it's got a few uh like plugins for
like text editors and things. So, DDEV
has more like support in that area.
Um it's also got a nice feature of
database uh snapshots, so you can take
like a binary backup of your
uh database when you're like doing
migrations rather than like dumping the
SQL file importing it. It can take like
a long time. So, it's got a few like
extra features and stuff. It's kind of
nice.
Um I will I promise I'm going to get
into the
uh more generalized uh options, just a
bit overview of the context of the
architecture. Um so, this is the
monolithic kind of containers that are
out of the box.
Um they're version controlled like the
tags, the Docker tags.
Just FYI, this you know, web server
version, whatever.
Uh this is the
folder structure of the dot DDEV folder.
Uh you can read on the screen, but
essentially um you got the config
uh YAML files. Um note that's YAML, not
YML.
Uh
and you got the main file, and then
there's the wildcards ones you can use a
config.whatever.yml
and it'll merge in together.
Um and there's a few different folders
where you can place uh different things
in, and then there's the build versions
of those folders. So, you got like
uh
web I don't think it's going to be
there. But anyway, DB build uh is like
you put your uh Dockerfile for your
database build. So, DDEV has its own
Dockerfile, and you can put like your
like a one liner, like add this program
to the DDEV build folder and then when
you run your project, it copies that
line in the DDEV
in the doc file in the DDEV build folder
to another
um folder called dot DDEV which build
dot dot which build yeah, so it combines
that all together and that's actually
what's run like underneath.
Um so some of them are like run time
folders and some are like your
configuration folders.
Um most of them have like
generated uh line
um
and you can read that line if you want
to edit anything and then subsequent
updates will not update that file. So
it's kind of like a layered
architecture.
So looking good. Cool. Um
One neat thing about DDEV um compared to
Lando is you has two options for the
configuration files. Uh you can
So by default it will like merge them
together like array like a nested array
merge. Um but it also has this uh line.
Um you can add called config override
true and then it will replace instead of
adding them together. So it's quite nice
if you're
got like uh
uh
maybe like follow follow volumes and you
don't want the top uh like the previous
volumes to be combined with your
volumes, you just want to override what
they are.
So that's more flexible in that area.
Um so yes, going back to the basics um
so yeah, just to start a project, I
think you might have done a first timers
um
session, but yeah, uh
to to run DDEV so after you install it
there's a like a
um it's very easy, there's a few
different ways to install it, so I'm not
going to go over that. Um
the yeah, you just create your folder,
then you run the DDEV config command
with your project type and your document
root.
Um by default it will take up the folder
name as the project name, but you can
override that.
If you're running like multiple projects
of the same name for some reason in
different like two folders in the same
name in different parent folders, then
you might want to use the project name.
But that's
that's what that is. If you're like,
"Oh, where's the project name?" Cool.
And then you run start and then it spins
up all the containers.
Uh and then yeah, it uh there's a .ddev
folder. Um bunch of things are
committed. I think it's in a different
slide, but essentially um
Oh, sorry. There's a bunch of
things that are ignored, but the basic
files just commit the config file when
you're sharing the project.
Uh
Yep. Cool. Um so there's some basic
things with like PHP and database
version. Um you just like do dash dash
PHP version equals blah blah blah. Um
Uh and you can also have the
configuration change like the PHP any
like the max execution execution time.
Um and that's placed in the .ddev
uh PHP any
/whatever.ini and it will pick it up.
And you can also it uh places it inside
the
uh like add-ons folder in the container.
So you can also use it to replace uh
things on purpose that are come like out
of box in the containers.
So that was PHP. This is uh the uh
database. The database has a
You can change the type like uh MySQL or
PostgreSQL or something. Um so that uses
slightly different
uh parameter.
Um similar type of thing you can also do
like mysql.cnf.
I'm not sure about Postgres
Postgres, but um yeah, the MariaDB and
MySQL use that folder for the
configuration files.
Uh oh, and it's uh it also supports
other ones like uh Microsoft SQL through
uh official plugins.
Um yeah, one thing that did surprise me
is DDEV comes out of the box with
Node.js engine um in the same monolithic
uh web container. So, it's kind of
good, I guess. Um
like you don't need to have separate
container. Uh it's um has a few
different ways of saying like the
version. Um but the most easiest is just
like dash dash Node.js version whatever.
And then um after you do this, you do
like DDEV restart. And it will like
apply the configuration.
Uh these are all the different commands.
I'm not going to go over um them all. Um
but essentially the biggest ones are the
the start um
DDEV start. So, like such project.
Uh stop is like, you know, when you
finish or you want to like not have many
like resources used on your computer.
Um and restart is um
not like Lando restart. Actually, it
will um it turns off your containers,
gets the Dockerfile cache, re-applies
your custom customizations on top, and
then
um starts the like turns on the
containers again. So, it's like delete
the container and then apply
configuration and turn it on again.
So, a little bit different. Not really
like all the volumes are kind of shared,
so you won't lose your data, but it is
something to note um if you're like just
edit some like system file in the
container and you thought uh your
change would be tracked, but no,
actually it'll be deleted. Um
Yeah, you'll have to use raw Docker
Compose uh commands to to uh
um
if you want to do a a real restart, not
just a fake restart.
Um thing.
Um
Forget Oh, and DDEV deletes a deletes a
project. Um by default it takes a
snapshot, so you might want to put like
omit snapshot. Um otherwise, it'll turn
on all your containers, take a snapshot,
and then it will delete the container.
So, but maybe you don't really care
about the project and you don't want to
back up, so just pass omit snapshot.
Uh the utility ones are just for like
debugging purpose, does the same as the
other one, just more um verbose
verbosity. Um
whereas the normal Ddev restart just has
like dots when it's like
building the container. Like maybe so it
has like certain versions
in-built like PHP version. And if you do
some version that's not in-built like
PHP 7, it will try and download that,
but you won't really see the the
progress.
So it's kind of nice if you're like,
"Oh, why is it taking so long?" You can
use the utility command.
Um there's some more notes there, but uh
yeah, you can see the GitHub um
for the uh like when I upload it later
um
to read that.
Um a few more things. You've got Ddev
SSH, similar to Lando SSH.
Um it's pretty straight forward. Um
Uh yeah, it's pretty much the same. Um
So for
I think it was Yeah, there's no
Lando update. Oh, sorry, there's Lando
update, but Ddev is um
uh
It's a kind of like built-in, I guess.
You don't update plugins like
separately.
Uh fine.
There's the snapshots and how to do like
add-ons.
It's got dash dash version. We'll have a
example of that later on.
Cool. Okay. Um you can do custom
commands. One really cool thing about
this is the custom command. So that's
like Ddev and then whatever command.
It's like Ddev Josh or something. You
can like make Josh do something. Um
You can uh set the container that it
runs on, which is similar to Lando, but
you can also make it run on the host
system. So maybe you want to affect I
don't know, do something on the host.
Maybe I haven't tested it, but maybe you
could run some ahoy command or something
or something with ping me, I guess. And
then
then whatever like else later on. Um but
that's kind of nice and it has the uh
format there on the screen.
It's not highlighted, but yeah, the dot
Ddev folder and then
where you want to run. And if it's host
uh for slash host, then it'll be the
host, otherwise it'll be like the name
of the container.
Uh that's example of how to
custom command called my bash. So you go
uh ddev
space my bash and then it does
something. This one just echoes some of
statement um and then execute the
command that you pass through it. So
this one just like
it goes and then like I passed it
past echo my parameter and it was
executed as well.
And you can also override. By default,
this my bash is the
command name, but you uh because that's
the file name, but if you you can have
different file name to the command if
you have the usage marker.
Um similarly, um
if you need like certain location for
your custom uh
default current directory, uh unlike
Lando where you have to specify in the
uh YAML file, uh
this one you um
have to use the bash commands. All the
commands are always bash. Um
so yeah, you run the CD uh command with
some different environmental variables
available.
Um and you can also set your own
environmental variable just like that
one on the screen.
Um yep. So with your out-of-the-box
containers, um
like anyone select different PHP version
or something, you might have to deal
with like custom SSL certificate. Um so
on like your working fields, we have
Zscaler and um
uh it scans everything, but your
container does not know about the
software. So it just thinks like, "Oh,
something's wrong with the connection
cuz there's no real authority to tell me
that Zscaler there is the um trusted."
So
um so in order to do some customization
to your uh software,
um and to get it trusted, there's
uh
Docker files you can use to change to
add the root certificate so it can get
trusted. And there's the pre Dockerfile.
So there's the Dockerfile.whatever and
the pre Dockerfile.
When in DB root or web root, um yeah, so
if you put in the pre then it will put
the certificate in earlier in the
container. Uh and then
when it downloads a new version of PHP,
it will like be trusted uh right and
just like
erroring and then you're like, "Oh,
what's going on?"
Um
yeah, and make sure it's PEM formatted.
It's
um
yeah, when you're exporting from your uh
computer.
There's like different SSL
uh formats.
Uh that's this example.
Create a file. File so it's just like
layered like I said before. Um have your
file and you put it in a certain
location and run update certificates.
And it'll run that when you do like the
DDEV restart.
Um yeah, so customizations, you can um
add some additional containers to for
your requirements. Uh you can also
remove the default containers for some
like if you maybe don't need a database,
you just run like static site. Then you
have this uh line in your config.yaml
file.
Um so that's great, makes it a bit
faster. Um and there's some sort of
hack, I'm not sure it's supported. Um
but if you want to use the web container
but you don't really like the default
kind of parameters in the Docker
Compose,
uh you can kind of like create like
layered
Docker Compose override files
which will merge with the original and
then you can add like a this reset uh in
one of the files and then the next file
in alphabetical order can have the real
configuration. That way it has it having
to merge of the array, it will like
remove the original array and then you
can have your new array. So it's a
complete replacement.
But it's not really like great but it's
option.
Um
yeah, uh with the web container I'll a
note there that uh it uses the PHP-FPM
by default, not web PHP. So, if you're
trying to replicate like 100% to your um
production website, it's um
uh not possible unless you like
yeah, have some new installation
instructions or you replace the web
container completely.
Uh yeah, that's what the Docker Compose
um wildcard looks like. So, um so the
base is like a box and the full is the
generated one. And you create some
wildcard matching that
format and then it will um yeah, be like
coming to the full file when you it
runs.
Uh that's an example of how to run a a
service. Um just need like container
name, um and the the ports and
environment, I think is the most key
things. Oh, and volumes, yes.
Container name,
uh ports, environment, volumes.
Um yep, so volumes is for like
um shared um metadata, I think, between
the containers, things like cut commands
or something like that. Um yep,
container name is like your name of your
service.
Uh
and the environment is like exposing
like certain ports.
Um the host name is just like it helps
you with your uh command prompt.
Uh and those ports is just like yeah,
allow some connections in. But you can
change the ports to something else, so
that's kind of nice.
A comment there.
Uh it's good. Oh yeah, you can um in
Lando, it
So, out of the box in Lando, the usual
way is like everything shares the same
domain name.
Yep. Um and but have different port
number.
But if you like prefix your domain name
for different um services, then you
uh can use edit the virtual host add
something in in front. So, this example
is solar.
So, that's how you can kind of get like
Lando kind of like functionality.
Cool. Um yeah, if you need to do
something based on your unique name, um,
like between services or something,
uh, it doesn't have it out of the box,
just something to note. Um, so you have
to create your own like name, and that
on the screen is the format to use.
That matches unique name.
You can add like additional programs.
Um, so when I researched this, uh, like
at the start, actually, I didn't realize
PV is already included. That's like the
progressive viewer.
Um,
but you can install other things. I just
tried to find some random packages that
aren't included.
Called htop. Um, this is a config.yml
file way of adding files. It will like
generate into a Dockerfile.
Um, but you can also, uh, do your own
like a custom way.
Um, like this on the screen with the
Dockerfiles.
Um, yep. You can also use, uh,
extra hook.
So when it runs, it will run some extra
command. Um,
this is good if you're if it's not
dependent on the internet because it's
not cached.
With the Dockerfile.
Um, but it's another way of running like
something locally.
You can actually Uh, database import,
um, it's pretty good, actually. It's
very performant already, the database
import. Um, you can do some small
optimization. I just did some small
thing with the, uh,
piping um,
directly without using the command, and
got like three per- uh,
three second increase. So it's around
like a 5% I guess. Not really that like
very, um,
not very advantageous, but it is a note
that you can increase it a little bit. I
think compared to like Drush, it's like
quite excellent.
Um, but yeah, that's a
that's how you like pipe it directly if
you want to bypass all the sanitization
checks and things.
Um, this is how to add-ons. You do the
add-on get, and then the thing there's a
registry uh, website on the screen.
Um, yeah, you remove the marker if you
want to edit some files for the plugin.
Uh, that's how to install a solid six
example. I need to wrap up. Um
Uh but yeah, you just like you get the
add-on, you restart, and then you just
turn on the Drupal modules, configure
it. Um and then uh yeah, it's it's
ready.
That's how I change the global port
number if you need to if you're running
like multiple project like routers on
your computer.
Uh note about um yeah, it's very quick
about Mutagen. So it has built-in uh
thing called Mutagen. Basically, uh
create some volume, which is kind of
like your real project in the container,
but it's not directly access your real
files.
So it's a kind of a copy edit the copy
of the files, and then it will
synchronize the files like later. So you
can have native performance, and then
your host will like catch up later. 2 to
10 times more performance. So it's kind
of cool. Uh that's just some notes on
the screen about like if you need to
configure it like explicitly, otherwise
it just kind of works out of the box. If
you have um
so Mutagen's for like the traditional
Windows, not the WSL, or Mac. Uh for
Linux and WSL it's not uh required.
But it just runs in the background.
About that's commands.
Um you can do extra files. I won't go
over this, but you can also map files.
You just have to note configuration to
make Mutagen not complain.
Uh I think that's it. Yeah, and that's
it. Um
Thanks for my uh
Uh yeah, listening to my presentation.
Um yeah, it'll uh the presentation will
go up on the GitHub. Um
But uh yeah, any quick questions? Um
feel free.
Any questions?
No?
>> Uh
so yeah, so I think
uh DDEV is pretty powerful, would you
say?
Um so my question first question, what's
the challenge between
you using DDEV working with another
uh architecture such as uh Vagrant?
How
manage to get
what's
what's the benefits you
get from
local
embassy
package or something like that?
That's my
question.
>> Yeah, so DDEV is more more reliable. So
the question sorry, the question is
about like using another local
development tool, how does it compare to
DDEV?
So yeah, DDEV is more reliable. It has
lots of tests, runs on like Windows and
Mac and and and links for everything.
Has a mutagen built in.
But compared to traditional like those
different tools, those tools are more
flexible. You got more options. It's not
like
fixed. So like example is like the
mutagen is like only does the root
directory. If your for some reason your
project, you may have lots of repos.
Maybe you want like this other folder to
be that's outside DDEV folder
to be the main project folder. You
cannot do that. It's like hard coded. So
some things you cannot really do. Some
things you can override but some things
you cannot do. So
yeah, for the other tools,
it's good if you need that flexibility
but if you don't need it, then using
DDEV is is better because it's more
reliable and easier to