Skip to content

Commit 60aa171

Browse files
committed
Add dev container and ddev config
1 parent 8a0a12d commit 60aa171

File tree

10 files changed

+13679
-14
lines changed

10 files changed

+13679
-14
lines changed

.ddev/config.yaml

Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
name: drupal-project
2+
type: drupal10
3+
docroot: web
4+
php_version: "8.2"
5+
webserver_type: nginx-fpm
6+
xdebug_enabled: false
7+
additional_hostnames: []
8+
additional_fqdns: []
9+
database:
10+
type: mariadb
11+
version: "10.11"
12+
use_dns_when_possible: true
13+
composer_version: "2"
14+
web_environment: []
15+
corepack_enable: false
16+
17+
# Key features of DDEV's config.yaml:
18+
19+
# name: <projectname> # Name of the project, automatically provides
20+
# http://projectname.ddev.site and https://projectname.ddev.site
21+
22+
# type: <projecttype> # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress
23+
# See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more
24+
# information on the different project types
25+
# "drupal" covers recent Drupal 8+
26+
27+
# docroot: <relative_path> # Relative path to the directory containing index.php.
28+
29+
# php_version: "8.2" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"
30+
31+
# You can explicitly specify the webimage but this
32+
# is not recommended, as the images are often closely tied to DDEV's' behavior,
33+
# so this can break upgrades.
34+
35+
# webimage: <docker_image> # nginx/php docker image.
36+
37+
# database:
38+
# type: <dbtype> # mysql, mariadb, postgres
39+
# version: <version> # database version, like "10.11" or "8.0"
40+
# MariaDB versions can be 5.5-10.8 and 10.11, MySQL versions can be 5.5-8.0
41+
# PostgreSQL versions can be 9-16.
42+
43+
# router_http_port: <port> # Port to be used for http (defaults to global configuration, usually 80)
44+
# router_https_port: <port> # Port for https (defaults to global configuration, usually 443)
45+
46+
# xdebug_enabled: false # Set to true to enable Xdebug and "ddev start" or "ddev restart"
47+
# Note that for most people the commands
48+
# "ddev xdebug" to enable Xdebug and "ddev xdebug off" to disable it work better,
49+
# as leaving Xdebug enabled all the time is a big performance hit.
50+
51+
# xhprof_enabled: false # Set to true to enable Xhprof and "ddev start" or "ddev restart"
52+
# Note that for most people the commands
53+
# "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better,
54+
# as leaving Xhprof enabled all the time is a big performance hit.
55+
56+
# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn
57+
58+
# timezone: Europe/Berlin
59+
# This is the timezone used in the containers and by PHP;
60+
# it can be set to any valid timezone,
61+
# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
62+
# For example Europe/Dublin or MST7MDT
63+
64+
# composer_root: <relative_path>
65+
# Relative path to the Composer root directory from the project root. This is
66+
# the directory which contains the composer.json and where all Composer related
67+
# commands are executed.
68+
69+
# composer_version: "2"
70+
# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1
71+
# to use the latest major version available at the time your container is built.
72+
# It is also possible to use each other Composer version channel. This includes:
73+
# - 2.2 (latest Composer LTS version)
74+
# - stable
75+
# - preview
76+
# - snapshot
77+
# Alternatively, an explicit Composer version may be specified, for example "2.2.18".
78+
# To reinstall Composer after the image was built, run "ddev debug refresh".
79+
80+
# nodejs_version: "20"
81+
# change from the default system Node.js version to any other version.
82+
# Numeric version numbers can be complete (i.e. 18.15.0) or
83+
# incomplete (18, 17.2, 16). 'lts' and 'latest' can be used as well along with
84+
# other named releases.
85+
# see https://www.npmjs.com/package/n#specifying-nodejs-versions
86+
# Note that you can continue using 'ddev nvm' or nvm inside the web container
87+
# to change the project's installed node version if you need to.
88+
89+
# corepack_enable: false
90+
# Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm
91+
92+
# additional_hostnames:
93+
# - somename
94+
# - someothername
95+
# would provide http and https URLs for "somename.ddev.site"
96+
# and "someothername.ddev.site".
97+
98+
# additional_fqdns:
99+
# - example.com
100+
# - sub1.example.com
101+
# would provide http and https URLs for "example.com" and "sub1.example.com"
102+
# Please take care with this because it can cause great confusion.
103+
104+
# upload_dirs: "custom/upload/dir"
105+
#
106+
# upload_dirs:
107+
# - custom/upload/dir
108+
# - ../private
109+
#
110+
# would set the destination paths for ddev import-files to <docroot>/custom/upload/dir
111+
# When Mutagen is enabled this path is bind-mounted so that all the files
112+
# in the upload_dirs don't have to be synced into Mutagen.
113+
114+
# disable_upload_dirs_warning: false
115+
# If true, turns off the normal warning that says
116+
# "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set"
117+
118+
# ddev_version_constraint: ""
119+
# Example:
120+
# ddev_version_constraint: ">= 1.22.4"
121+
# This will enforce that the running ddev version is within this constraint.
122+
# See https://github.com/Masterminds/semver#checking-version-constraints for
123+
# supported constraint formats
124+
125+
# working_dir:
126+
# web: /var/www/html
127+
# db: /home
128+
# would set the default working directory for the web and db services.
129+
# These values specify the destination directory for ddev ssh and the
130+
# directory in which commands passed into ddev exec are run.
131+
132+
# omit_containers: [db, ddev-ssh-agent]
133+
# Currently only these containers are supported. Some containers can also be
134+
# omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit
135+
# the "db" container, several standard features of DDEV that access the
136+
# database container will be unusable. In the global configuration it is also
137+
# possible to omit ddev-router, but not here.
138+
139+
# performance_mode: "global"
140+
# DDEV offers performance optimization strategies to improve the filesystem
141+
# performance depending on your host system. Should be configured globally.
142+
#
143+
# If set, will override the global config. Possible values are:
144+
# - "global": uses the value from the global config.
145+
# - "none": disables performance optimization for this project.
146+
# - "mutagen": enables Mutagen for this project.
147+
# - "nfs": enables NFS for this project.
148+
#
149+
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#nfs
150+
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#mutagen
151+
152+
# fail_on_hook_fail: False
153+
# Decide whether 'ddev start' should be interrupted by a failing hook
154+
155+
# host_https_port: "59002"
156+
# The host port binding for https can be explicitly specified. It is
157+
# dynamic unless otherwise specified.
158+
# This is not used by most people, most people use the *router* instead
159+
# of the localhost port.
160+
161+
# host_webserver_port: "59001"
162+
# The host port binding for the ddev-webserver can be explicitly specified. It is
163+
# dynamic unless otherwise specified.
164+
# This is not used by most people, most people use the *router* instead
165+
# of the localhost port.
166+
167+
# host_db_port: "59002"
168+
# The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic
169+
# unless explicitly specified.
170+
171+
# mailpit_http_port: "8025"
172+
# mailpit_https_port: "8026"
173+
# The Mailpit ports can be changed from the default 8025 and 8026
174+
175+
# host_mailpit_port: "8025"
176+
# The mailpit port is not normally bound on the host at all, instead being routed
177+
# through ddev-router, but it can be bound directly to localhost if specified here.
178+
179+
# webimage_extra_packages: [php7.4-tidy, php-bcmath]
180+
# Extra Debian packages that are needed in the webimage can be added here
181+
182+
# dbimage_extra_packages: [telnet,netcat]
183+
# Extra Debian packages that are needed in the dbimage can be added here
184+
185+
# use_dns_when_possible: true
186+
# If the host has internet access and the domain configured can
187+
# successfully be looked up, DNS will be used for hostname resolution
188+
# instead of editing /etc/hosts
189+
# Defaults to true
190+
191+
# project_tld: ddev.site
192+
# The top-level domain used for project URLs
193+
# The default "ddev.site" allows DNS lookup via a wildcard
194+
# If you prefer you can change this to "ddev.local" to preserve
195+
# pre-v1.9 behavior.
196+
197+
# ngrok_args: --basic-auth username:pass1234
198+
# Provide extra flags to the "ngrok http" command, see
199+
# https://ngrok.com/docs/ngrok-agent/config or run "ngrok http -h"
200+
201+
# disable_settings_management: false
202+
# If true, DDEV will not create CMS-specific settings files like
203+
# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php
204+
# In this case the user must provide all such settings.
205+
206+
# You can inject environment variables into the web container with:
207+
# web_environment:
208+
# - SOMEENV=somevalue
209+
# - SOMEOTHERENV=someothervalue
210+
211+
# no_project_mount: false
212+
# (Experimental) If true, DDEV will not mount the project into the web container;
213+
# the user is responsible for mounting it manually or via a script.
214+
# This is to enable experimentation with alternate file mounting strategies.
215+
# For advanced users only!
216+
217+
# bind_all_interfaces: false
218+
# If true, host ports will be bound on all network interfaces,
219+
# not the localhost interface only. This means that ports
220+
# will be available on the local network if the host firewall
221+
# allows it.
222+
223+
# default_container_timeout: 120
224+
# The default time that DDEV waits for all containers to become ready can be increased from
225+
# the default 120. This helps in importing huge databases, for example.
226+
227+
#web_extra_exposed_ports:
228+
#- name: nodejs
229+
# container_port: 3000
230+
# http_port: 2999
231+
# https_port: 3000
232+
#- name: something
233+
# container_port: 4000
234+
# https_port: 4000
235+
# http_port: 3999
236+
# Allows a set of extra ports to be exposed via ddev-router
237+
# Fill in all three fields even if you don’t intend to use the https_port!
238+
# If you don’t add https_port, then it defaults to 0 and ddev-router will fail to start.
239+
#
240+
# The port behavior on the ddev-webserver must be arranged separately, for example
241+
# using web_extra_daemons.
242+
# For example, with a web app on port 3000 inside the container, this config would
243+
# expose that web app on https://<project>.ddev.site:9999 and http://<project>.ddev.site:9998
244+
# web_extra_exposed_ports:
245+
# - name: myapp
246+
# container_port: 3000
247+
# http_port: 9998
248+
# https_port: 9999
249+
250+
#web_extra_daemons:
251+
#- name: "http-1"
252+
# command: "/var/www/html/node_modules/.bin/http-server -p 3000"
253+
# directory: /var/www/html
254+
#- name: "http-2"
255+
# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000"
256+
# directory: /var/www/html
257+
258+
# override_config: false
259+
# By default, config.*.yaml files are *merged* into the configuration
260+
# But this means that some things can't be overridden
261+
# For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge
262+
# and you can't erase existing hooks or all environment variables.
263+
# However, with "override_config: true" in a particular config.*.yaml file,
264+
# 'use_dns_when_possible: false' can override the existing values, and
265+
# hooks:
266+
# post-start: []
267+
# or
268+
# web_environment: []
269+
# or
270+
# additional_hostnames: []
271+
# can have their intended affect. 'override_config' affects only behavior of the
272+
# config.*.yaml file it exists in.
273+
274+
# Many DDEV commands can be extended to run tasks before or after the
275+
# DDEV command is executed, for example "post-start", "post-import-db",
276+
# "pre-composer", "post-composer"
277+
# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more
278+
# information on the commands that can be extended and the tasks you can define
279+
# for them. Example:
280+
#hooks:
281+
# post-import-db:
282+
# - exec: drush sql:sanitize
283+
# - exec: drush updatedb
284+
# - exec: drush cache:rebuild

.devcontainer/devcontainer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/debian
3+
{
4+
"name": "Drupal Starter Project (docker-in-docker)",
5+
"image": "mcr.microsoft.com/devcontainers/php:1-8.2",
6+
7+
//"build": {
8+
//"dockerfile": "Dockerfile",
9+
// Update 'VARIANT' to pick an Debian version: bullseye, buster, stretch
10+
// Use bullseye or stretch on local arm64/Apple Silicon.
11+
//"args": { "VARIANT": "bullseye" }
12+
//},
13+
14+
// Set *default* container specific settings.json values on container create.
15+
"settings": {},
16+
17+
// Add the IDs of extensions you want installed when the container is created.
18+
"extensions": [],
19+
20+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
21+
22+
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
23+
//"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
24+
25+
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
26+
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
27+
28+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
29+
"remoteUser": "vscode",
30+
31+
//"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
32+
//"workspaceFolder": "${localWorkspaceFolder}",
33+
34+
"postCreateCommand": "bash .devcontainer/init-container.sh",
35+
36+
"features": {
37+
"ghcr.io/devcontainers/features/docker-in-docker:1": {},
38+
"ghcr.io/ddev/ddev/install-ddev:latest": {}
39+
}
40+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/debian
3+
{
4+
"name": "Drupal Starter Project (docker-outside-of-docker)",
5+
"image": "mcr.microsoft.com/devcontainers/php:1-8.2",
6+
7+
//"build": {
8+
//"dockerfile": "Dockerfile",
9+
// Update 'VARIANT' to pick an Debian version: bullseye, buster, stretch
10+
// Use bullseye or stretch on local arm64/Apple Silicon.
11+
//"args": { "VARIANT": "bullseye" }
12+
//},
13+
14+
// Set *default* container specific settings.json values on container create.
15+
"settings": {},
16+
17+
// Add the IDs of extensions you want installed when the container is created.
18+
"extensions": [],
19+
20+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
21+
22+
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
23+
"mounts": [
24+
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
25+
"source=${localEnv:HOME},target=/home/vscode,type=bind",
26+
//"source=/mnt,target=/mnt,type=bind"
27+
],
28+
29+
"customizations": {
30+
"vscode": {
31+
// Set *default* container specific settings.json values on container create.
32+
"settings": {
33+
// Prevent VS Code's automatic port forwarding
34+
"remote.autoForwardPorts": false,
35+
"remote.restoreForwardedPorts": false,
36+
"remote.forwardOnOpen": false,
37+
},
38+
"extensions": [],
39+
}
40+
41+
42+
},
43+
44+
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
45+
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
46+
47+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
48+
"remoteUser": "vscode",
49+
50+
"containerEnv": {
51+
"CAROOT": "/home/vscode/.local/share/mkcert",
52+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
53+
},
54+
55+
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
56+
"workspaceFolder": "${localWorkspaceFolder}",
57+
58+
"postCreateCommand": "bash .devcontainer/init-container.sh",
59+
60+
"features": {
61+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
62+
"ghcr.io/ddev/ddev/install-ddev:latest": {}
63+
}
64+
}

.devcontainer/init-container.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
ddev config global --instrumentation-opt-in=false
4+
[ $CODESPACES ] || mkcert -install
5+
composer install --ignore-platform-reqs
6+
7+
echo "Use \`ddev start\` to run the Drupal site."

0 commit comments

Comments
 (0)