Skip to content

Commit 1d59d47

Browse files
committed
Reorganize the project with a containers-first mindset.
1 parent 892e908 commit 1d59d47

24 files changed

+15316
-111
lines changed

Diff for: example.env renamed to .env

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# @file: Env variables for local development. Update as needed.
2+
# In case you need sensitive data, e.g. some external API keys,
3+
# you can add a .local.env file, add it to gitignore and add it
4+
# to the required services (e.g. php) with the env_file key
5+
# in the docker-compose.yml file.
6+
# Alternatively, use a docker-compse.local.yml
17
PROJECT_NAME=damopen
28
PROJECT_BASE_URL=damopen.docker.localhost
39

@@ -15,7 +21,7 @@ DRUPAL_HASH_SALT="<random string - at least 72 characters long>"
1521
DRUPAL_DATABASE_NAME=drupal
1622
DRUPAL_DATABASE_USERNAME=drupal
1723
DRUPAL_DATABASE_PASSWORD=drupal
18-
DRUPAL_DATABASE_HOST=mariadb
24+
DRUPAL_DATABASE_HOST=db
1925
DRUPAL_DATABASE_PORT=3306
2026

2127
DB_ROOT_PASSWORD=drupal

Diff for: .gitignore

+4-41
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,15 @@
1-
# Ignore directories generated by Composer
2-
drush/contrib
3-
vendor
4-
bin
5-
web/core
6-
web/libraries
7-
web/modules/contrib
8-
web/themes/contrib
9-
web/profiles/contrib
10-
11-
# Ignore Drupal's file directory
12-
web/sites/default/files
13-
private/*
14-
private_files/*
15-
tmp/*
16-
171
# Ignore files generated by PhpStorm
182
.idea
193

204
# Ignore apple stuff
215
.DS_Store
226

23-
# Ignore configuration files that may contain sensitive information.
24-
web/sites/*/settings.local.php
25-
web/sites/*/settings.devdesktop.php
26-
web/sites/*/services*.yml
27-
28-
# Ignore paths that contain user-generated content.
29-
web/sites/*/files
30-
web/sites/*/private
31-
web/sites/*/private_files
32-
33-
# Ignore SimpleTest multi-site environment.
34-
web/sites/simpletest
35-
36-
# Ignore Acquia Dev Desktop configs.
37-
web/sites/*.dd
38-
397
# Ignore .env files as they are personal
40-
/.env
418
.editorconfig
429
.gitattributes
4310

44-
docker-compose.local.yml
45-
46-
drush/local
11+
tmp
12+
vendor
4713

48-
/settings/*.php
49-
!/settings/settings.proxy.php
50-
!/settings/settings.trusted-hosts.php
51-
# As this is just a bootstrap file here with sensitive values fetched from the env we can and should add it to git.
52-
!/web/sites/default/settings.php
14+
.local.env
15+
docker-compose.local.yml

Diff for: README.md

+29-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ This template was based on the following:
88
- [Drupal recommended project](https://www.drupal.org/docs/develop/using-composer/starting-a-site-using-drupal-composer-project-templates)
99
- [Thunder distro](https://github.com/thunder/thunder-project).
1010

11+
## Structure
12+
13+
- `app`: the actual Drupal folder. This is the only folder mounted into the docker container, installing Drupal, adding dependencies, using drush, etc. should be executed from here.
14+
- Note, in a containerized environment this is the only folder that should be available to the image at build time.
15+
- Git root should still be the project root.
16+
- `docker`: contains Dockerfiles and some helpers for building the images
17+
1118
## Installation
1219

1320
Note: These commands have been tested on linux (ubuntu), they might need changes to work on other systems.
@@ -36,29 +43,46 @@ For a specific release:
3643
DAMOPEN_PROJECT_DIR=my-damopen-project; mkdir "${DAMOPEN_PROJECT_DIR}" && docker run --rm -u "$(id -u)":"$(id -g)" -w /app --mount type=bind,src="$(pwd)"/"${DAMOPEN_PROJECT_DIR}",dst=/app brainsum/damopen-php:7.4-dev-4.22.1 composer create-project brainsum/damopen-project=2.0.x-dev .
3744
```
3845

39-
Note: The wodby/drupal-php image is just an example.
40-
Note: Using an image with the `hirak/prestissimo` composer package will speed up the process, although it also might break things (see: <https://github.com/drupal-composer/drupal-scaffold/issues/101>).
46+
This creates the base structure. After the project installed, you need to enter go to the `app` folder and use `composer install`.
47+
48+
Note: Drupal released 9.2, but the damopen distro applies a patch that's not compatible with that version. If `composer install` fails, you can work around this by adding the following to `app/composer.json` / extra (See: `cweagans/composer-patches`) and running it again:
49+
```json
50+
"patches": {
51+
"Implement a generic revision UI (Drupal 9.2)": "https://www.drupal.org/files/issues/2021-03-24/2350939-164.patch"
52+
},
53+
"patches-ignore": {
54+
"brainsum/damopen": {
55+
"drupal/core": {
56+
"Implement a generic revision UI": "https://www.drupal.org/files/issues/2021-02-04/2350939-156-9.1.x.patch"
57+
}
58+
}
59+
},
60+
```
4161

4262
## Setup
4363

4464
### Environment variables
4565

46-
By default, the project depends on some environment variables. See the [settings.php scaffold file](./composer/damopen/assets/default.settings.php) as well the files in the [settings folder](./settings).
66+
By default, the project depends on some environment variables. See the [settings.php](./app/web/sites/default/settings.php) as well the files in the [settings folder](./app/settings).
4767

4868
### (Optional) Docker-compose
4969

50-
If you want to use docker-compose for development, you should copy `example.env` as `.env`, e.g `cp example.env .env`. Update its contents as required.
70+
If you want to use docker-compose for development, you should update `.env` as needed (e.g. replaceing damopen with your project's name, adding the hash salt, ...).
5171

5272
For starting and stopping the environment you can use the helper scripts provided with the project (`startup.sh` and `shutdown.sh`). These also look for a `docker-compose.local.yml` file so you can version control a generic config file and do local overrides (e.g ports, mounts).
5373

5474
### Drush
5575

56-
Copy `drush/example.drush.yml` as `drush/drush.yml`. Update its contents as required.
76+
Copy `app/drush/example.drush.yml` as `app/drush/drush.yml` and update its contents as required.
5777

5878
### Filesystem permission fixes
5979

6080
E.g. on linux, you must fix file and directory permissions as well, e.g for "private_files", "web/sites/default/files", "tmp", ...
6181

82+
### Additional settings files
83+
84+
`app/settings/example` contains multiple pre-defined settings files. Copy `settings.local.php` to `settings` to bootstrap your local settings, `web/sites/default/settings.php` automatically includes it, if present. This helps avoid issues with file permissions for the main `settings.php`.
85+
6286
### Install
6387

6488
Use `drush site-install --account-pass=somestrongpass [email protected] --site-name=DAMopen damopen -y`

Diff for: app/.dockerignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/web/core
2+
/web/libraries
3+
/web/modules/contrib
4+
/web/themes/contrib
5+
/web/profiles/contrib
6+
/web/sites/default/files
7+
/private_files
8+
/tmp
9+
/drush/contrib
10+
/drush/local
11+
/vendor

Diff for: app/.gitignore

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/web/.csslintrc
2+
/web/.eslintignore
3+
/web/.eslintrc.json
4+
/web/.ht.router.php
5+
/web/.htaccess
6+
/web/INSTALL.txt
7+
/web/README.txt
8+
/web/autoload.php
9+
/web/example.gitignore
10+
/web/index.php
11+
/web/update.php
12+
/web/web.config
13+
14+
# Ignore SimpleTest multi-site environment.
15+
/web/sites/simpletest
16+
# Ignore Acquia Dev Desktop configs.
17+
/web/sites/*.dd
18+
19+
/web/sites/default/default.services.yml
20+
/web/sites/default/default.settings.php
21+
/web/sites/development.services.yml
22+
/web/sites/example.settings.local.php
23+
/web/sites/example.sites.php
24+
25+
/settings/*.php
26+
!/settings/settings.proxy.php
27+
!/settings/settings.trusted-hosts.php
28+
29+
# Ignore directories generated by Composer
30+
/drush/contrib
31+
/drush/local
32+
33+
/vendor
34+
/bin
35+
/web/core
36+
/web/libraries
37+
/web/modules/contrib
38+
/web/themes/contrib
39+
/web/profiles/contrib
40+
41+
# Ignore Drupal's file directory
42+
/web/sites/default/files
43+
/private_files
44+
/tmp

Diff for: app/composer.json

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"name": "brainsum/damopen-drupal",
3+
"description": "Drupal application for DAMOpen.",
4+
"type": "project",
5+
"license": "GPL-2.0-or-later",
6+
"authors": [
7+
{
8+
"name": "mhavelant",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"minimum-stability": "dev",
13+
"prefer-stable": true,
14+
"config": {
15+
"apcu-autoloader": true,
16+
"optimize-autoloader": true,
17+
"sort-packages": true
18+
},
19+
"repositories": {
20+
"drupal-8": {
21+
"type": "composer",
22+
"url": "https://packages.drupal.org/8"
23+
},
24+
"asset-packagist": {
25+
"type": "composer",
26+
"url": "https://asset-packagist.org"
27+
}
28+
},
29+
"require": {
30+
"php": "^7.3",
31+
"brainsum/damopen": "^1.0.0",
32+
"composer/installers": "^1.11.0",
33+
"cweagans/composer-patches": "^1.7.0",
34+
"drupal/admin_toolbar": "^3.0.0",
35+
"drupal/adminimal_admin_toolbar": "^1.11.0",
36+
"drupal/core-composer-scaffold": "^9.1.8",
37+
"drupal/core-recommended": "^9.1.8",
38+
"drupal/exception_mailer": "^3.0@beta",
39+
"drupal/maillog": "^1.0@beta",
40+
"drush/drush": "^10.5.0",
41+
"oomphinc/composer-installers-extender": "^2.0.0"
42+
},
43+
"require-dev": {
44+
"drupal-composer/drupal-security-advisories": "8.x-dev",
45+
"drupal/console": "^1.9.7",
46+
"drupal/core-dev": "^9.1.8",
47+
"drupal/devel": "^4.1.1",
48+
"drupal/devel_entity_updates": "^3.0.1",
49+
"drupal/devel_php": "^1.3.0",
50+
"roave/security-advisories": "dev-master"
51+
},
52+
"conflict": {
53+
"drupal/drupal": "*"
54+
},
55+
"extra": {
56+
"enable-patching": true,
57+
"composer-exit-on-patch-failure": true,
58+
"patches": {},
59+
"drupal-scaffold": {
60+
"locations": {
61+
"web-root": "web/"
62+
},
63+
"file-mapping": {
64+
"[web-root]/sites/default/settings.php": false,
65+
"[web-root]/sites/default/services.yml": false,
66+
"[web-root]/sites/.gitignore": false,
67+
"[web-root]/sites/README.txt": false,
68+
"[web-root]/modules/.gitignore": false,
69+
"[web-root]/modules/README.txt": false,
70+
"[web-root]/profiles/.gitignore": false,
71+
"[web-root]/profiles/README.txt": false,
72+
"[web-root]/themes/.gitignore": false,
73+
"[web-root]/themes/README.txt": false,
74+
"[web-root]/robots.txt": false
75+
},
76+
"initial": {
77+
".editorconfig": "[web-root]/.editorconfig",
78+
".gitattributes": "[web-root]/.gitattributes"
79+
}
80+
},
81+
"installer-paths": {
82+
"web/core": ["type:drupal-core"],
83+
"web/libraries/{$name}": [
84+
"type:drupal-library",
85+
"type:bower-asset",
86+
"type:npm-asset"
87+
],
88+
"web/modules/contrib/{$name}": ["type:drupal-module"],
89+
"web/profiles/contrib/{$name}": ["type:drupal-profile"],
90+
"web/themes/contrib/{$name}": ["type:drupal-theme"],
91+
"drush/Commands/contrib/{$name}": ["type:drupal-drush"],
92+
"web/modules/custom/{$name}": ["type:drupal-custom-module"],
93+
"web/profiles/custom/{$name}": ["type:drupal-custom-profile"],
94+
"web/themes/custom/{$name}": ["type:drupal-custom-theme"]
95+
},
96+
"installer-types": ["bower-asset", "npm-asset"]
97+
}
98+
}

0 commit comments

Comments
 (0)