diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..6b8710a711 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/.env b/.env new file mode 100644 index 0000000000..d0771577b4 --- /dev/null +++ b/.env @@ -0,0 +1,109 @@ +### Documentation available at https://wodby.com/docs/stacks/drupal/local +### Changelog can be found at https://github.com/wodby/docker4drupal/releases +### Images tags format explained at https://github.com/wodby/docker4drupal#images-tags + +### PROJECT SETTINGS + +PROJECT_NAME=my_drupal11_project +PROJECT_BASE_URL=drupal.docker.localhost +PROJECT_PORT=8000 + +DB_NAME=drupal +DB_USER=drupal +DB_PASSWORD=drupal +DB_ROOT_PASSWORD=password +DB_HOST=mariadb +DB_PORT=3306 +DB_DRIVER=mysql + +### --- MARIADB ---- + +MARIADB_TAG=11.8-3.34.1 +#MARIADB_TAG=11.4-3.34.1 +#MARIADB_TAG=10.11-3.34.1 +#MARIADB_TAG=10.6-3.34.1 + +### --- DRUPAL CMS ---- + +DRUPAL_CMS_TAG=1-0.14.1 + +### --- VANILLA DRUPAL ---- + +DRUPAL_TAG=11-4.91.1 +#DRUPAL_TAG=10-4.91.1 + +### --- PHP ---- + +# Linux (uid 1000 gid 1000) + +PHP_TAG=8.4-dev-4.75.1 +#PHP_TAG=8.3-dev-4.75.1 +#PHP_TAG=8.2-dev-4.75.1 +#PHP_TAG=8.1-dev-4.75.1 + +# macOS (uid 501 gid 20) + +#PHP_TAG=8.4-dev-macos-4.75.1 +#PHP_TAG=8.3-dev-macos-4.75.1 +#PHP_TAG=8.2-dev-macos-4.75.1 +#PHP_TAG=8.1-dev-macos-4.75.1 + +### --- NGINX ---- + +NGINX_TAG=1.29-5.46.1 +#NGINX_TAG=1.28-5.46.1 + +NGINX_VHOST_PRESET=drupal11 +#NGINX_VHOST_PRESET=drupal10 + +### --- SOLR --- + +SOLR_TAG=9-5.4.0 + +### --- OPENSEARCH --- + +OPENSEARCH_TAG=2 +OPENSEARCH_ADMIN_PASSWORD=VERY%@bad123password + +### --- VALKEY --- + +VALKEY_TAG=9.0-1.5.0 +#VALKEY_TAG=8.1-1.5.0 +#VALKEY_TAG=8.0-1.5.0 +#VALKEY_TAG=7-1.5.0 + +### --- REDIS --- + +REDIS_TAG=8.2-5.1.0 +#REDIS_TAG=8.0-5.1.0 +#REDIS_TAG=7.4-5.1.0 + +### --- NODE --- + +NODE_TAG=24-dev-1.63.0 +#NODE_TAG=22-dev-1.63.0 +#NODE_TAG=20-dev-1.63.0 + +### --- VARNISH --- + +VARNISH_TAG=6.0-4.23.2 + +### --- POSTGRESQL ---- + +POSTGRES_TAG=18-1.38.0 +#POSTGRES_TAG=17-1.38.0 +#POSTGRES_TAG=16-1.38.0 +#POSTGRES_TAG=15-1.38.0 +#POSTGRES_TAG=14-1.38.0 + +### OTHERS + +ADMINER_TAG=5-5.0.1 +APACHE_TAG=2.4-4.17.0 +MEMCACHED_TAG=1-2.21.0 +OPENSMTPD_TAG=7-1.27.1 +RSYSLOG_TAG=latest +SELENIUM_CHROME_TAG=3.141 +WEBGRIND_TAG=1-1.42.1 +XHPROF_TAG=3.20.1 +ZOOKEEPER_TAG=3.8 diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md new file mode 100644 index 0000000000..db72c170bd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -0,0 +1,39 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + +***OS type*** +Linux/Windows/macOS + +***Drupal version*** +7 / 8 + +***Codebase*** +Built-in vanilla Drupal or mounted codebase + +**Describe the bug** +A clear and concise description of what the bug is. + +**Output of `docker info`** +``` +Paste here +``` + +**Contents of your `compose.yml`** +``` +Paste here +REMOVE COMMENTED LINES +``` + +**Contents of your `.env`** +``` +Paste here +REMOVE COMMENTED LINES +``` + +**Logs output `docker compose logs`** +``` +Paste here +``` diff --git a/.github/ISSUE_TEMPLATE/Custom.md b/.github/ISSUE_TEMPLATE/Custom.md new file mode 100644 index 0000000000..5b5cf5b007 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Custom.md @@ -0,0 +1,31 @@ +--- +name: Support request +about: Request support from community + +--- + +***Codebase*** +Built-in vanilla Drupal or mounted codebase + +**Describe your issue** +A clear and concise description of your issue. + +**Output of `docker info`** +``` +Paste here +``` + +**Contents of your `compose.yml`** +``` +Paste here +``` + +**Contents of your `.env`** +``` +Paste here +``` + +**Logs output `docker compose logs`** +``` +Paste here +``` diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md new file mode 100644 index 0000000000..5384295126 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/issue_template.md b/.github/issue_template.md new file mode 100644 index 0000000000..374ec121b0 --- /dev/null +++ b/.github/issue_template.md @@ -0,0 +1,26 @@ +### Codebase +Built-in vanilla Drupal or mounted codebase + +### Host OS +e.g. macOS Sierra + +### Docker info output +``` +# Run "docker info" on the host machine and paste output here +``` + +### Docker compose file +Make sure you remove all commented services. +```yml +# Content of your compose.yml file. Make sure you remove all sensible information you might have there. +``` + +### .env file +``` +# Content of .env file. Make sure you remove all sensible information you might have there. +``` + +### Logs output +``` +# Run "docker compose logs [service]". Let's say you get 500 error for some reason then it'll be helpful to provide logs for php and http server (nginx/apache) services. +``` diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000000..0e35ec44f4 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,58 @@ +name: Run tests + +on: + push: + branches: + - master + + tags: + - '*' + + pull_request: + +jobs: + test: + strategy: + matrix: + drupal_ver: [ 11,10 ] + php_ver: [ '8.4','8.3','8.2','8.1' ] + exclude: + - drupal_ver: 11 + php_ver: '8.2' + - drupal_ver: 11 + php_ver: '8.1' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: test + env: + DRUPAL_VER: ${{ matrix.drupal_ver }} + PHP_VER: ${{ matrix.php_ver }} + run: make test + test-cms: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: test + run: make test-cms + release: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + needs: [test,test-cms] + steps: + - uses: actions/checkout@v4 + - name: prepare artifact + run: cp docker.mk Makefile && tar -czf docker4drupal.tar.gz compose.yml compose.override.yml Makefile .env traefik.yml + - name: get tag name + id: vars + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + - uses: xresloader/upload-to-github-release@v1 + id: upload_artifact + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: docker4drupal.tar.gz + overwrite: true + tags: true + draft: false + tag_name: ${{ steps.vars.outputs.tag }} diff --git a/.gitignore b/.gitignore index b1fecc7b0d..875c38cd9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .idea/ -docker-runtime/ +mariadb-init +postgres-init +mutagen.yml.lock +.vscode \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000000..c3cec398ee --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright (c) 2016 Wodby, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..2ffba95e2d --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +include docker.mk + +DRUPAL_VER ?= 11 +PHP_VER ?= 8.4 + +test: + cd ./tests/$(DRUPAL_VER) && PHP_VER=$(PHP_VER) ./run.sh +.PHONY: test + +test-cms: + cd ./tests/cms && ./run.sh +.PHONY: test-cms diff --git a/README.md b/README.md index 9432b12fb5..740da0d856 100644 --- a/README.md +++ b/README.md @@ -1,302 +1,172 @@ -# Native docker-based local environment for Drupal +# Docker-based Drupal stack -Use this Docker compose file to spin up local environment for Drupal with a *native Docker app* on Linux, Mac OS X and Windows. - -Docker4Drupal is designed to be used for local development, if you're looking for a dev/staging/production solution check out Wodby. Use Wodby to deploy container-based infrastructure consistent with Docker4Drupal to any server. - ---- - -* [Overview](#overview) -* [Instructions](#instructions) -* [Containers](#containers) - * [Accessing containers](#accessing-containers) - * [Nginx](#nginx) - * [PHP](#php) - * [Drush](#drush) - * [Composer](#composer) - * [Drupal Console](#drupal-console) - * [Xdebug](#xdebug) - * [MariaDB](#mariadb) - * [Import](#import) - * [Export](#export) - * [Redis](#redis) - * [Memcached](#memcached) - * [Memcached Admin](#memcached-admin) - * [Mailhog](#mailhog) - * [phpMyAdmin](#phpmyadmin) - * [Apache Solr](#apache-solr) - * [Varnish](#varnish) -* [Multiple projects](#multiple-projects) -* [Docroot in subdirectory](#docroot-in-subdirectory) -* [Logs](#logs) -* [Status](#status) +[![Build Status](https://github.com/wodby/docker4drupal/workflows/Run%20tests/badge.svg)](https://github.com/wodby/docker4drupal/actions) -## Overview +## Introduction -The Drupal bundle consist of the following containers: +Docker4Drupal is a set of docker images optimized for Drupal. Use +`compose.yml` file from the [latest stable release](https://github.com/wodby/docker4drupal/releases) to spin up local environment on Linux, Mac OS X and Windows. -| Container | Service name | Image | Public Port | Enabled by default | -| --------- | ------------ | ----- | ----------- | ------------------ | -| [Nginx](#nginx) | nginx | wodby/drupal-nginx | 8000 | ✓ | -| [PHP 7 / 5.6](#php) | php | wodby/drupal-php | | ✓ | -| [MariaDB](#mariadb) | mariadb | wodby/drupal-mariadb | | ✓ | -| [phpMyAdmin](#phpmyadmin) | pma | phpmyadmin/phpmyadmin | 8001 | ✓ | -| [Mailhog](#mailhog) | mailhog | mailhog/mailhog | 8002 | ✓ | -| [Redis](#redis) | redis | redis/redis ||| -| [Memcached](#memcached) | memcached | _/memcached ||| -| [Solr](#solr) | solr | _/solr | 8003 || -| [Varnish](#varnish) | varnish | wodby/drupal-varnish | 8004 || +* Read the docs on [**how to use**](https://wodby.com/docs/stacks/drupal/local#usage) +* Ask questions on [Discord](http://discord.wodby.com/) +* Ask questions on [Slack](http://slack.wodby.com/) +* Follow [@wodbycloud](https://twitter.com/wodbycloud) for future announcements -PHP, Nginx, MariaDB and Varnish configs are optimized to be used with Drupal. We regularly update this bundle with performance improvements, bug fixes and newer version of Nginx/PHP/MariaDB. +## Stack -## Instructions +The Drupal stack consist of the following containers: -__Feel free to adjust volumes and ports in the compose file for your convenience.__ +| Container | Versions | Image | ARM64 support | Enabled by default | +|-----------------------|-------------------------|-------------------------------------------|---------------|--------------------| +| [Nginx] | 1.29, 1.28 | [wodby/nginx] | ✓ | ✓ | +| [Apache] | 2.4 | [wodby/apache] | ✓ | | +| Drupal CMS | 1 | [wodby/drupal-cms] | ✓ | ✓ | +| Vanilla Drupal | 11, 10 | [wodby/drupal] | ✓ | | +| [PHP] | 8.4, 8.3, 8.2, 8.1 | [wodby/drupal-php] | ✓ | | +| Crond | | [wodby/drupal-php] | ✓ | ✓ | +| [MariaDB] | 11.8, 11.4, 10.11, 10.6 | [wodby/mariadb] | ✓ | ✓ | +| [PostgreSQL] | 18, 17, 16, 15, 14 | [wodby/postgres] | ✓ | | +| [Valkey] | 9.0, 8.1, 8.0, 7 | [wodby/valkey] | ✓ | | +| [Redis] | 8.2, 8.0, 7.4 | [wodby/redis] | ✓ | | +| [Memcached] | 1.6 | [wodby/memcached] | ✓ | | +| [Varnish] | 6.0 | [wodby/varnish] | ✓ | | +| [Node.js] | 24, 22, 20 | [wodby/node] | ✓ | | +| [Solr] | 9 | [wodby/solr] | ✓ | | +| Zookeeper | 3.8 | [zookeeper] | ✓ | | +| OpenSearch | 2 | [opensearchproject/opensearch] | ✓ | | +| OpenSearch Dashboards | 2 | [opensearchproject/opensearch-dashboards] | ✓ | | +| [OpenSMTPD] | 7 | [wodby/opensmtpd] | ✓ | | +| Mailpit | latest | [axllent/mailpit] | ✓ | ✓ | +| Gotenberg | latest | [gotenberg/gotenberg] | ✓ | | +| [Rsyslog] | latest | [wodby/rsyslog] | ✓ | | +| [Webgrind] | 1 | [wodby/webgrind] | ✓ | | +| [Xhprof viewer] | latest | [wodby/xhprof] | ✓ | | +| Adminer | 5 | [wodby/adminer] | ✓ | | +| phpMyAdmin | latest | [phpmyadmin/phpmyadmin] | | | +| Selenium chrome | 3.141 | [selenium/standalone-chrome] | | | +| Traefik | latest | [_/traefik] | ✓ | ✓ | -Supported Drupal versions: 7 and 8 +## Documentation -Supported PHP versions: 7.x and 5.6.x. +Full documentation is available at https://wodby.com/docs/stacks/drupal/local. -1\. Install docker for Linux, Mac OS X or Windows. __For Mac and Windows make sure you're installing native docker app version 1.12, not docker toolbox.__ +## Image's tags -For Linux additionally install docker compose +Images' tags format is `[VERSION]-[STABILITY_TAG]` where: -2\. Download the compose file from this repository and put it to your Drupal project codebase (you might want to add docker-compose.yml to .gitignore). +`[VERSION]` is the _version of an application_ (without patch version) running in a container, e.g. +`wodby/nginx:1.15-x.x.x` where Nginx version is `1.15` and +`x.x.x` is a stability tag. For some images we include both major and minor version like PHP +`7.2`, for others we include only major like Valkey `7`. -3\. Since containers do not have a permanent storage, directories from the host machine (volumes) should be mounted: one with code of your Drupal project and another with database files. +`[STABILITY_TAG]` is the _version of an image_ that corresponds to a git tag of the image repository, e.g. +`wodby/mariadb:10.2-3.3.8` has MariaDB `10.2` and stability tag [ +`3.3.8`](https://github.com/wodby/mariadb/releases/tag/3.3.8). New stability tags include patch updates for applications and image's fixes/improvements (new env vars, orchestration actions fixes, etc). Stability tag changes described in the corresponding a git tag description. Stability tags follow [semantic versioning](https://semver.org/). -By default, the directory with the compose file (volume `./`) will be mounted to PHP container (assuming it's your codebase directory). Additionally `docker-runtime` directory will be created to store files for mariadb and, optionally, solr containers. Do not forget to add `docker-runtime` to your .gitignore file. +We highly encourage to use images only with stability tags. -**Linux only**: fix permissions for your files directory with: -```bash -$ sudo chgrp -R 82 sites/default/files -$ sudo chmod -R 775 sites/default/files -``` +## Maintenance -4\. Choose Drupal version by modifying the following environment variable (could be 7 or 8) in the compose file: -```yml -DRUPAL_VERSION: 8 -``` +We regularly update images used in this stack and release them together, see [releases page](https://github.com/wodby/docker4drupal/releases) for full changelog and update instructions. Most of routine updates for images and this project performed by [the bot](https://github.com/wodbot) via scripts located at [wodby/images](https://github.com/wodby/images). -5\. Choose PHP version by modifying the name of the image: -```yml -image: wodby/drupal-php:7.0 # Allowed: 7.0, 5.6 -``` +## Beyond local environment -6\. Update database credentials in your settings.php file: -``` -database: drupal -username: drupal -password: drupal -host: mariadb -``` +Docker4Drupal is a project designed to help you spin up local environment with Docker Compose. If you want to deploy a consistent stack with orchestrations to your own server, check out [Drupal stack](https://wodby.com/stacks/drupal) on Wodby ![](https://www.google.com/s2/favicons?domain=wodby.com). -7\. If you want to import your database, uncomment the following line in the compose file: -```yml -# - ./docker-runtime/mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here -``` +## Other Docker4x projects -Create the volume directory `./docker-runtime/mariadb-init` in the same directory as the compose file and put there your SQL file(s). All SQL files will be automatically imported once MariaDB container has started. +* [docker4php](https://github.com/wodby/docker4php) +* [docker4laravel](https://github.com/wodby/docker4laravel) +* [docker4wordpress](https://github.com/wodby/docker4wordpress) +* [docker4ruby](https://github.com/wodby/docker4ruby) +* [docker4python](https://github.com/wodby/docker4python) -8\. If you need to deploy one of the optional containers ([Redis](#redis), [Memcached](#memcached), [Apache Solr](#apache-solr)) uncomment the corresponding lines in the compose file. +## License -9\. Now, let's run the compose file. It will download the images and run the containers: -```bash -$ docker-compose up -d -``` +This project is licensed under the MIT open source license. -10\. Make sure all containers are running by executing: +[Apache]: https://wodby.com/docs/stacks/drupal/containers#apache -```bash -$ docker-compose ps -``` +[Drupal CMS]: https://wodby.com/docs/stacks/drupal/containers#php -11\. That's it! You drupal website should be up and running at http://localhost:8000. +[Vanilla Drupal]: https://wodby.com/docs/stacks/drupal/containers#php -## Containers +[MariaDB]: https://wodby.com/docs/stacks/drupal/containers#mariadb -### Accessing containers +[Memcached]: https://wodby.com/docs/stacks/drupal/containers#memcached -You can connect to any container by executing the following command: -```bash -$ docker-compose exec php sh -``` +[Nginx]: https://wodby.com/docs/stacks/drupal/containers#nginx -Replace `php` with the name of your service (e.g. `mariadb`, `nginx`, etc). +[Node.js]: https://wodby.com/docs/stacks/drupal/containers#nodejs -### Nginx +[OpenSMTPD]: https://wodby.com/docs/stacks/drupal/containers#opensmtpd -Nginx is being used as a web server. Nginx is pre-configured to be used with Drupal 7 and 8. +[PHP]: https://wodby.com/docs/stacks/drupal/containers#php -### PHP +[PostgreSQL]: https://wodby.com/docs/stacks/drupal/containers#postgresql -PHP is used with Nginx via PHP-FPM. Currently PHP version 5.6 and 7 are provided. Check out [the instructions (step 5)](#instructions) to learn how to switch the version. +[Redis]: https://wodby.com/docs/stacks/drupal/containers#redis -#### Drush +[Valkey]: https://wodby.com/docs/stacks/drupal/containers#valkey -PHP container has installed drush. When running drush make sure to open the shell as user 82 (www-data) to avoid access problems in the web server, which is running as user 82, too: -```bash -$ docker-compose exec --user 82 php drush -``` +[Rsyslog]: https://wodby.com/docs/stacks/drupal/containers#rsyslog -Also, you can use preconfigured drush alias @dev: -```bash -$ docker-compose exec --user 82 php drush @dev -``` +[Solr]: https://wodby.com/docs/stacks/drupal/containers#solr -#### Composer +[Varnish]: https://wodby.com/docs/stacks/drupal/containers#varnish -PHP container has installed composer. Example: -```bash -$ docker-compose exec --user 82 php composer update -``` +[Webgrind]: https://wodby.com/docs/stacks/drupal/containers#webgrind -#### Drupal Console +[XHProf viewer]: https://wodby.com/docs/stacks/php/containers#xhprof-viewer -PHP container has installed drupal console. Example: -```bash -$ docker-compose exec --user 82 php drupal list -``` +[_/traefik]: https://hub.docker.com/_/traefik -#### Xdebug +[gotenberg/gotenberg]: https://hub.docker.com/r/gotenberg/gotenberg -If you want to use Xdebug, uncomment this line to enable it in the compose file before starting containers: +[axllent/mailpit]: https://hub.docker.com/r/axllent/mailpit -```yml -PHP_XDEBUG_ENABLED: 1 # Comment out to disable (default). -``` +[phpmyadmin/phpmyadmin]: https://hub.docker.com/r/phpmyadmin/phpmyadmin -If you would like to autostart Xdebug, uncomment this line: +[selenium/standalone-chrome]: https://hub.docker.com/r/selenium/standalone-chrome -```yml -PHP_XDEBUG_AUTOSTART: 1 # Comment out to disable (default). -``` +[wodby/adminer]: https://hub.docker.com/r/wodby/adminer -#### Xdebug on Mac OS X +[wodby/apache]: https://github.com/wodby/apache -There are two more things that need to be done on Mac OS X in order to have Xdebug working. Uncomment `PHP_XDEBUG_ENABLED` to enable Xdebug and uncomment the following two lines: +[wodby/drupal-php]: https://github.com/wodby/drupal-php -```yml -PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # Disabled for remote.host to work (enabled by default) -PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # Setting the host (localhost by default) -``` +[wodby/drupal]: https://github.com/wodby/drupal -It is also needed to have localhost loopback alias with IP from above. You need this only once and that settings stays active until logout or restart. +[wodby/drupal-cms]: https://github.com/wodby/drupal-cms -```bash -sudo ifconfig lo0 alias 10.254.254.254 -``` +[wodby/mariadb]: https://github.com/wodby/mariadb -For more details see the issue with Xdebug in Mac OS. +[wodby/memcached]: https://github.com/wodby/memcached -### MariaDB +[wodby/nginx]: https://github.com/wodby/nginx -#### Configuring +[wodby/node]: https://github.com/wodby/node -Many configuration options can be passed as flags without adjusting a cnf file. See example in the compose file: -```bash -# command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci -``` +[wodby/opensmtpd]: https://github.com/wodby/opensmtpd -#### Import +[wodby/postgres]: https://github.com/wodby/postgres -Check out [the instructions (step 7)](#instructions) to learn how to import your existing database. +[wodby/valkey]: https://github.com/wodby/valkey -#### Export +[wodby/redis]: https://github.com/wodby/redis -Exporting all databases: +[wodby/rsyslog]: https://hub.docker.com/r/wodby/rsyslog -```bash -docker-compose exec mariadb sh -c 'exec mysqldump --all-databases -uroot -p"root-password"' > databases.sql -``` +[wodby/solr]: https://github.com/wodby/solr -Exporting a specific database: +[wodby/varnish]: https://github.com/wodby/varnish -```bash -docker-compose exec mariadb sh -c 'exec mysqldump -uroot -p"root-password" my-db' > my-db.sql -``` +[wodby/webgrind]: https://hub.docker.com/r/wodby/webgrind -### Redis +[wodby/xhprof]: https://hub.docker.com/r/wodby/xhprof -To spin up a container with Redis cache and use it as a default cache storage follow these steps: +[zookeeper]: https://hub.docker.com/_/zookeeper -1. Uncomment lines with redis service definition in the compose file. -2. Download and install redis module -3. Add the following lines to the settings.php file: +[opensearchproject/opensearch]: https://hub.docker.com/r/opensearchproject/opensearch -```php -$conf['redis_client_host'] = 'redis'; -$conf['redis_client_interface'] = 'PhpRedis'; -$conf['lock_inc'] = $contrib_path . '/redis/redis.lock.inc'; -$conf['path_inc'] = $contrib_path . '/redis/redis.path.inc'; -$conf['cache_backends'][] = 'sites/all/modules/redis/redis.autoload.inc'; -$conf['cache_default_class'] = 'Redis_Cache'; -$conf['cache_class_cache_form'] = 'DrupalDatabaseCache'; -``` - -### Memcached - -To spin up a container with Memcached and use it as a default cache storage follow these steps: - -1. Uncomment lines with memcached service definition in the compose file. -2. Download and install memcache module -3. Add the following lines to the settings.php file: - -```php -$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc'; -$conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc'; -$conf['memcache_stampede_protection'] = TRUE; -$conf['cache_default_class'] = 'MemCacheDrupal'; -$conf['cache_class_cache_form'] = 'DrupalDatabaseCache'; -$conf['memcache_servers'] = array('memcached:11211' => 'default'); -``` - -### Memcached Admin - -To spin up a container with the Memcached Admin User interface uncomment to memcached-admin service definition. -To get started visit http://localhost:8006/index.php - -### Mailhog - -By default, container with mailhog included in the bundle. It will catch all email sent from the PHP container. You can view emails by visiting its admin UI on localhost:8002. - -### phpMyAdmin - -By default, container with phpMyAdmin included in the bundle. You can access it by localhost:8001 - -### Apache Solr - -To spin up a container with Apache Solr search engine uncomment lines with solr service definition in the compose file. Use volume directory `./docker-runtime/solr` to access configuration files. Solr admin UI can be accessed by localhost:8003 - -### Varnish - -To spin up a container with Varnish uncomment lines with varnish service definition in the compose file. Use the port specified in the compose file to access the website via Varnish. - -## Multiple projects - -To use D4D with multiple projects simply adjust the ports in the compose file, e.g. instead of ports 8000, 8001, 8002 you can use 7000, 7001, 7002. - -## Docroot in subdirectory - -If your docroot located in a subdirectory use options `PHP_DOCROOT` and `NGINX_DOCROOT` to specify the path (relative path inside the /var/www/html/ directory) for PHP and Nginx containers. - -## Logs - -To get logs from a container simply run (skip the last param to get logs form all the containers): -``` -$ docker-compose logs [service] -``` - -Example: real-time logs of the PHP container: -``` -$ docker-compose logs -f php -``` - -## Status - -We're actively working on this instructions and containers. More options will be added soon. If you have a feature request or found a bug please submit an issue. - -We update containers from time to time, to get the lastest changes simply run again: -``` -$ docker-compose up -d -``` +[opensearchproject/opensearch-dashboards]: https://hub.docker.com/r/opensearchproject/opensearch-dashboards diff --git a/compose.override.yml b/compose.override.yml new file mode 100644 index 0000000000..bddf31f1f6 --- /dev/null +++ b/compose.override.yml @@ -0,0 +1,27 @@ +services: + php: + image: wodby/drupal-cms:$DRUPAL_CMS_TAG +# image: wodby/drupal:$DRUPAL_TAG + environment: + PHP_FPM_CLEAR_ENV: "no" + volumes: + - codebase:/var/www/html + + crond: + image: wodby/drupal-cms:$DRUPAL_CMS_TAG +# image: wodby/drupal:$DRUPAL_TAG + environment: + PHP_FPM_CLEAR_ENV: "no" + volumes: + - codebase:/var/www/html + + nginx: + volumes: + - codebase:/var/www/html + +# webgrind: +# volumes: +# - codebase:/mnt/codebase + +volumes: + codebase: diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000000..f59aab1316 --- /dev/null +++ b/compose.yml @@ -0,0 +1,309 @@ +services: + mariadb: + image: wodby/mariadb:$MARIADB_TAG + container_name: "${PROJECT_NAME}_mariadb" + stop_grace_period: 30s + environment: + MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD + MYSQL_DATABASE: $DB_NAME + MYSQL_USER: $DB_USER + MYSQL_PASSWORD: $DB_PASSWORD + MYSQL_TRANSACTION_ISOLATION: READ-COMMITTED +# volumes: +# - ./mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here. +# - /path/to/mariadb/data/on/host:/var/lib/mysql # Use bind mount + + php: + image: wodby/drupal-php:$PHP_TAG + container_name: "${PROJECT_NAME}_php" + environment: + # By default xdebug extension also disabled. + PHP_EXTENSIONS_DISABLE: xhprof,spx + PHP_MAIL_MIXED_LF_AND_CRLF: 'On' + # Mailpit: + MSMTP_HOST: mailpit + MSMTP_PORT: 1025 +# # OpenSMTPD: +# MSMTP_HOST: opensmtpd +# MSMTP_PORT: 25 +# DB_HOST: $DB_HOST +# DB_PORT: $DB_PORT +# DB_USER: $DB_USER +# DB_PASSWORD: $DB_PASSWORD +# DB_NAME: $DB_NAME +# DB_DRIVER: $DB_DRIVER +# DRUSH_OPTIONS_URI: "http://${PROJECT_BASE_URL}:${PROJECT_PORT}" +# PHP_FPM_USER: wodby +# PHP_FPM_GROUP: wodby +# COLUMNS: 80 # Set 80 columns for docker exec -it. +# # Read instructions at https://wodby.com/docs/stacks/php/local/#xdebug +# PHP_XDEBUG_MODE: debug +# PHP_XDEBUG_MODE: profile +# PHP_XDEBUG_USE_COMPRESSION: false +# PHP_IDE_CONFIG: serverName=my-ide +# PHP_XDEBUG_IDEKEY: "my-ide" +# PHP_XDEBUG_LOG: /tmp/php-xdebug.log +# # PHPUnit Drupal testing configurations +# SIMPLETEST_BASE_URL: "http://nginx/" +# SIMPLETEST_DB: "${DB_DRIVER}://${DB_USER}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}#tests_" +# MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-gpu","--headless"]}}, "http://chrome:9515/"]' + extra_hosts: + - "host.docker.internal:host-gateway" + volumes: + - ./:/var/www/html:cached +## Alternative for macOS users: Mutagen https://wodby.com/docs/stacks/drupal/local#docker-for-mac +# - drupal:/var/www/html +## For XHProf and Xdebug profiler traces +# - files:/mnt/files + + crond: + init: true + image: wodby/drupal-php:$PHP_TAG + container_name: "${PROJECT_NAME}_crond" + environment: + CRONTAB: "0 * * * * drush -r /var/www/html/web cron" + command: sudo -E crond -f -d 0 + volumes: + - ./:/var/www/html:cached +## Alternative for macOS users: Mutagen https://wodby.com/docs/stacks/drupal/local#docker-for-mac +# - drupal:/var/www/html + + nginx: + image: wodby/nginx:$NGINX_TAG + container_name: "${PROJECT_NAME}_nginx" + depends_on: + - php + environment: + NGINX_STATIC_OPEN_FILE_CACHE: "off" + NGINX_ERROR_LOG_LEVEL: debug + NGINX_BACKEND_HOST: php + NGINX_SERVER_ROOT: /var/www/html/web + NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET + # NGINX_DRUPAL_FILE_PROXY_URL: http://example.com + volumes: + - ./:/var/www/html:cached +## Alternative for macOS users: Mutagen https://wodby.com/docs/stacks/drupal/local#docker-for-mac +# - drupal:/var/www/html + labels: + - "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`)" + + mailpit: + image: axllent/mailpit + container_name: "${PROJECT_NAME}_mailpit" + labels: + - "traefik.http.services.${PROJECT_NAME}_mailpit.loadbalancer.server.port=8025" + - "traefik.http.routers.${PROJECT_NAME}_mailpit.rule=Host(`mailpit.${PROJECT_BASE_URL}`)" + +# postgres: +# image: wodby/postgres:$POSTGRES_TAG +# container_name: "${PROJECT_NAME}_postgres" +# stop_grace_period: 30s +# environment: +# POSTGRES_PASSWORD: $DB_PASSWORD +# POSTGRES_DB: $DB_NAME +# POSTGRES_USER: $DB_USER +# POSTGRES_DB_EXTENSIONS: pg_trgm +# volumes: +# - ./postgres-init:/docker-entrypoint-initdb.d # Place init file(s) here. +# - /path/to/postgres/data/on/host:/var/lib/postgresql/data # Use bind mount + +# apache: +# image: wodby/apache:$APACHE_TAG +# container_name: "${PROJECT_NAME}_apache" +# depends_on: +# - php +# environment: +# APACHE_LOG_LEVEL: debug +# APACHE_BACKEND_HOST: php +# APACHE_VHOST_PRESET: php +# APACHE_DOCUMENT_ROOT: /var/www/html/web +# volumes: +# - ./:/var/www/html:cached +## Alternative for macOS users: Mutagen https://wodby.com/docs/stacks/drupal/local#docker-for-mac +# - drupal:/var/www/html + +# labels: +# - "traefik.http.routers.${PROJECT_NAME}_apache.rule=Host(`${PROJECT_BASE_URL}`)" + +# varnish: +# image: wodby/varnish:$VARNISH_TAG +# container_name: "${PROJECT_NAME}_varnish" +# depends_on: +# - nginx +# environment: +# VARNISH_SECRET: secret +# VARNISH_BACKEND_HOST: nginx +# VARNISH_BACKEND_PORT: 80 +# VARNISH_CONFIG_PRESET: drupal +# VARNISH_ALLOW_UNRESTRICTED_PURGE: 1 +# labels: +# - "traefik.http.services.${PROJECT_NAME}_varnish.loadbalancer.server.port=6081" +# - "traefik.http.routers.${PROJECT_NAME}_varnish.rule=Host(`varnish.${PROJECT_BASE_URL}`)" + +# valkey: +# container_name: "${PROJECT_NAME}_valkey" +# image: wodby/valkey:$VALKEY_TAG + +# redis: +# container_name: "${PROJECT_NAME}_redis" +# image: wodby/redis:$REDIS_TAG + +# adminer: +# container_name: "${PROJECT_NAME}_adminer" +# init: true +# image: wodby/adminer:$ADMINER_TAG +# environment: +# # For PostgreSQL: +# # ADMINER_DEFAULT_DB_DRIVER: pgsql +# ADMINER_DEFAULT_DB_HOST: $DB_HOST +# ADMINER_DEFAULT_DB_NAME: $DB_NAME +# labels: +# - "traefik.http.routers.${PROJECT_NAME}_adminer.rule=Host(`adminer.${PROJECT_BASE_URL}`)" + +# pma: +# image: phpmyadmin/phpmyadmin +# container_name: "${PROJECT_NAME}_pma" +# environment: +# PMA_HOST: $DB_HOST +# PMA_USER: $DB_USER +# PMA_PASSWORD: $DB_PASSWORD +# UPLOAD_LIMIT: 1G +# labels: +# - "traefik.http.routers.${PROJECT_NAME}_pma.rule=Host(`pma.${PROJECT_BASE_URL}`)" + +# solr: +# image: wodby/solr:$SOLR_TAG +# container_name: "${PROJECT_NAME}_solr" +# environment: +# SOLR_OPTS: "-Dsolr.config.lib.enabled=true" +# SOLR_MODULES: extraction,langid,ltr,analysis-extras +# ZK_HOST: zookeeper:2181 +# SOLR_HEAP: 1024m +# depends_on: +# - zookeeper +# labels: +# - "traefik.http.services.${PROJECT_NAME}_solr.loadbalancer.server.port=8983" +# - "traefik.http.routers.${PROJECT_NAME}_solr.rule=Host(`solr.${PROJECT_BASE_URL}`)" + +# zookeeper: +# image: zookeeper:$ZOOKEEPER_TAG +# container_name: "${PROJECT_NAME}_zookeeper" +# environment: +# ZOO_MY_ID: 1 +# ZOO_SERVERS: server.1=zookeeper:2888:3888;2181 +# ZOO_4LW_COMMANDS_WHITELIST: mntr, conf, ruok + +# memcached: +# container_name: "${PROJECT_NAME}_memcached" +# image: wodby/memcached:$MEMCACHED_TAG + +# rsyslog: +# container_name: "${PROJECT_NAME}_rsyslog" +# image: wodby/rsyslog:$RSYSLOG_TAG + +# gotenberg: +# image: gotenberg/gotenberg +# container_name: "${PROJECT_NAME}_gotenberg" + +# node: +# image: wodby/node:$NODE_TAG +# container_name: "${PROJECT_NAME}_node" +# working_dir: /var/www/html/path/to/theme/to/build +# labels: +# - "traefik.http.services.${PROJECT_NAME}_node.loadbalancer.server.port=3000" +# - "traefik.http.routers.${PROJECT_NAME}_node.rule=Host(`node.${PROJECT_BASE_URL}`)" +# expose: +# - "3000" +# volumes: +# - ./:/var/www/html +# command: sh -c 'yarn install && yarn run start' + +# webgrind: +# image: wodby/webgrind:$WEBGRIND_TAG +# container_name: "${PROJECT_NAME}_webgrind" +# environment: +# WEBGRIND_PROFILER_DIR: /mnt/files/xdebug +# labels: +# - "traefik.http.routers.${PROJECT_NAME}_webgrind.rule=Host(`webgrind.${PROJECT_BASE_URL}`)" +# volumes: +# - files:/mnt/files +# - ./:/mnt/codebase:cached + +# opensearch: +# image: opensearchproject/opensearch:$OPENSEARCH_TAG +# environment: +# "discovery.type": "single-node" +# "plugins.security.disabled": true +# OPENSEARCH_INITIAL_ADMIN_PASSWORD: $OPENSEARCH_ADMIN_PASSWORD +# +# opensearch-dashboards: +# image: opensearchproject/opensearch-dashboards:$OPENSEARCH_TAG +# environment: +# OPENSEARCH_HOSTS: '["http://opensearch:9200/"]' +# DISABLE_SECURITY_DASHBOARDS_PLUGIN: true +# depends_on: +# - opensearch +# labels: +# - "traefik.http.services.${PROJECT_NAME}_opensearch.loadbalancer.server.port=5601" +# - "traefik.http.routers.${PROJECT_NAME}_opensearch.rule=Host(`opensearch.${PROJECT_BASE_URL}`)" + +# opensmtpd: +# container_name: "${PROJECT_NAME}_opensmtpd" +# image: wodby/opensmtpd:$OPENSMTPD_TAG + +# xhprof: +# image: wodby/xhprof:$XHPROF_TAG +# container_name: "${PROJECT_NAME}_xhprof" +# restart: always +# volumes: +# - files:/mnt/files +# labels: +# - "traefik.http.routers.${PROJECT_NAME}_xhprof.rule=Host(`xhprof.${PROJECT_BASE_URL}`)" + +# chrome: +# image: selenium/standalone-chrome:$SELENIUM_CHROME_TAG +# container_name: "${PROJECT_NAME}_chrome" +# volumes: +# - /dev/shm:/dev/shm +# entrypoint: +# - chromedriver +# - "--no-sandbox" +# - "--disable-dev-shm-usage" +# - "--log-path=/tmp/chromedriver.log" +# - "--verbose" +# - "--whitelisted-ips=" + + traefik: + image: traefik:v2.0 + container_name: "${PROJECT_NAME}_traefik" + command: --api.insecure=true --providers.docker + ports: + - "${PROJECT_PORT}:80" +# - '8080:8080' # Dashboard + volumes: + - /var/run/docker.sock:/var/run/docker.sock + +#x-mutagen: +# sync: +# defaults: +# ignore: +# vcs: true +# paths: +# - .DS_Store +# - .history +# - .idea +# drupal: +# alpha: "." +# beta: "volume://drupal" +# configurationBeta: +# permissions: +# defaultFileMode: 0644 +# defaultDirectoryMode: 0755 +# defaultOwner: "id:501" +# defaultGroup: "id:20" + +volumes: +## For macOS users (Mutagen) +# drupal: +# For Xdebug profiler + files: diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index d30d997a55..0000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,101 +0,0 @@ -version: "2" - -services: - mariadb: - image: wodby/drupal-mariadb - environment: - MYSQL_RANDOM_ROOT_PASSWORD: 1 - MYSQL_DATABASE: drupal - MYSQL_USER: drupal - MYSQL_PASSWORD: drupal -# command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci # The simple way to override the mariadb config. - volumes: - - ./docker-runtime/mariadb:/var/lib/mysql -# - ./docker-runtime/mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here. - - php: - image: wodby/drupal-php:7.0 # Allowed: 7.0, 5.6. - environment: - PHP_SITE_NAME: dev - PHP_HOST_NAME: localhost:8000 -# PHP_DOCROOT: public # Relative path inside the /var/www/html/ directory. - PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 - # PHP_XDEBUG_ENABLED: 1 - # PHP_XDEBUG_AUTOSTART: 1 - # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow - # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254' - volumes: - - ./:/var/www/html - - nginx: - image: wodby/drupal-nginx - environment: - NGINX_SERVER_NAME: localhost - NGINX_UPSTREAM_NAME: php -# NGINX_DOCROOT: public # Relative path inside the /var/www/html/ directory. - DRUPAL_VERSION: 8 # Allowed: 7, 8. - volumes_from: - - php - ports: - - "8000:80" - - pma: - image: phpmyadmin/phpmyadmin - environment: - PMA_HOST: mariadb - PMA_USER: drupal - PMA_PASSWORD: drupal - PHP_UPLOAD_MAX_FILESIZE: 1G - PHP_MAX_INPUT_VARS: 1G - ports: - - "8001:80" - - mailhog: - image: mailhog/mailhog - ports: - - "8002:8025" - -# redis: -# image: redis:3.2-alpine - -# memcached: -# image: memcached:1.4-alpine - -# memcached-admin: -# image: phynias/phpmemcachedadmin -# ports: -# - "8006:80" - -# solr: -# image: solr:5.5-alpine -# volumes: -# - ./docker-runtime/solr:/opt/solr/server/solr/mycores -# entrypoint: -# - docker-entrypoint.sh -# - solr-precreate -# - main -# ports: -# - "8003:8983" - -# varnish: -# image: wodby/drupal-varnish -# depends_on: -# - nginx -# environment: -# VARNISH_SECRET: secret -# VARNISH_BACKEND_HOST: nginx -# VARNISH_BACKEND_PORT: 80 -# VARNISH_MEMORY_SIZE: 256M -# VARNISH_STORAGE_SIZE: 1024M -# ports: -# - "8004:6081" # HTTP Proxy -# - "8005:6082" # Control terminal - -# sshd: -# image: wodby/drupal-sshd -# environment: -# SSH_PUB_KEY: "ssh-rsa ..." -# volumes_from: -# - php -# ports: -# - "8006:22" diff --git a/docker.mk b/docker.mk new file mode 100644 index 0000000000..788454f006 --- /dev/null +++ b/docker.mk @@ -0,0 +1,89 @@ +include .env + +default: up + +COMPOSER_ROOT ?= /var/www/html +DRUPAL_ROOT ?= /var/www/html/web + +## help : Print commands help. +.PHONY: help +ifneq (,$(wildcard docker.mk)) +help : docker.mk + @sed -n 's/^##//p' $< +else +help : Makefile + @sed -n 's/^##//p' $< +endif + +## up : Start up containers. +.PHONY: up +up: + @echo "Starting up containers for $(PROJECT_NAME)..." + docker compose pull + docker compose up -d --remove-orphans + +.PHONY: mutagen +mutagen: + mutagen-compose up + +## down : Stop containers. +.PHONY: down +down: stop + +## start : Start containers without updating. +.PHONY: start +start: + @echo "Starting containers for $(PROJECT_NAME) from where you left off..." + @docker compose start + +## stop : Stop containers. +.PHONY: stop +stop: + @echo "Stopping containers for $(PROJECT_NAME)..." + @docker compose stop + +## prune : Remove containers and their volumes. +## You can optionally pass an argument with the service name to prune single container +## prune mariadb : Prune `mariadb` container and remove its volumes. +## prune mariadb solr : Prune `mariadb` and `solr` containers and remove their volumes. +.PHONY: prune +prune: + @echo "Removing containers for $(PROJECT_NAME)..." + @docker compose down -v $(filter-out $@,$(MAKECMDGOALS)) + +## ps : List running containers. +.PHONY: ps +ps: + @docker ps --filter name='$(PROJECT_NAME)*' + +## shell : Access `php` container via shell. +## You can optionally pass an argument with a service name to open a shell on the specified container +.PHONY: shell +shell: + docker exec -ti -e COLUMNS=$(shell tput cols) -e LINES=$(shell tput lines) $(shell docker ps --filter name='$(PROJECT_NAME)_$(or $(filter-out $@,$(MAKECMDGOALS)), 'php')' --format "{{ .ID }}") sh + +## composer : Executes `composer` command in a specified `COMPOSER_ROOT` directory (default is `/var/www/html`). +## To use "--flag" arguments include them in quotation marks. +## For example: make composer "update drupal/core --with-dependencies" +.PHONY: composer +composer: + docker exec $(shell docker ps --filter name='^/$(PROJECT_NAME)_php' --format "{{ .ID }}") composer --working-dir=$(COMPOSER_ROOT) $(filter-out $@,$(MAKECMDGOALS)) + +## drush : Executes `drush` command in a specified `DRUPAL_ROOT` directory (default is `/var/www/html/web`). +## To use "--flag" arguments include them in quotation marks. +## For example: make drush "watchdog:show --type=cron" +.PHONY: drush +drush: + docker exec $(shell docker ps --filter name='^/$(PROJECT_NAME)_php' --format "{{ .ID }}") drush -r $(DRUPAL_ROOT) $(filter-out $@,$(MAKECMDGOALS)) + +## logs : View containers logs. +## You can optinally pass an argument with the service name to limit logs +## logs php : View `php` container logs. +## logs nginx php : View `nginx` and `php` containers logs. +.PHONY: logs +logs: + @docker compose logs -f $(filter-out $@,$(MAKECMDGOALS)) + +# https://stackoverflow.com/a/6273809/1826109 +%: + @: diff --git a/index.php b/index.php deleted file mode 100644 index 83f154933a..0000000000 --- a/index.php +++ /dev/null @@ -1,3 +0,0 @@ ->"${PWD}/sites/default/settings.php" + +# Enable redis +check_rq "Redis" "Connected" + +check_rq "Trusted Host Settings" "Enabled" + +# Import solr server +drush cim --source=/var/www/html/solr --partial -y +drush solr-upload-conf solr +drush sapi-sl | grep -q enabled + +## Test varnish cache and purge +drush ppadd varnish +drush cr + +## Workaround for varnish purger import https://www.drupal.org/node/2856221 +PURGER_ID=$(drush ppls --format=json | jq -r "keys[0]") + +mkdir -p /var/www/html/varnish +# We copy mounted file because we can't edit mounted file (resource busy error). +cp /var/www/html/varnish-purger.yml /var/www/html/varnish/purger.yml +sed -i "s/PLUGIN_ID/${PURGER_ID}/g" /var/www/html/varnish/purger.yml +mv /var/www/html/varnish/purger.yml "/var/www/html/varnish/varnish_purger.settings.${PURGER_ID}.yml" +drush -y cim --source=/var/www/html/varnish --partial +drush -y config-set system.performance cache.page.max_age 43200 + +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: MISS" +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: HIT" + +drush cc render +drush pqw + +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: MISS" +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: HIT" diff --git a/tests/10/varnish-purger.yml b/tests/10/varnish-purger.yml new file mode 100644 index 0000000000..9f763d9ee5 --- /dev/null +++ b/tests/10/varnish-purger.yml @@ -0,0 +1,25 @@ +uuid: 91faa2b9-fd7a-4419-8dae-fc5a91b782b6 +langcode: en +status: true +dependencies: { } +id: PLUGIN_ID +name: 'Varnish 4.1' +invalidationtype: tag +hostname: varnish +port: 6081 +path: / +request_method: BAN +scheme: http +verify: '1' +headers: + - + field: Cache-Tags + value: '[invalidation:expression]' +body: null +body_content_type: null +runtime_measurement: true +timeout: !!float 1 +connect_timeout: !!float 1 +cooldown_time: !!float 0 +max_requests: 100 +http_errors: true diff --git a/tests/11/.env b/tests/11/.env new file mode 100644 index 0000000000..2186681cf2 --- /dev/null +++ b/tests/11/.env @@ -0,0 +1,16 @@ +DB_NAME=drupal +DB_USER=drupal +DB_PASSWORD=drupal +DB_ROOT_PASSWORD=password +DB_HOST=mariadb +DB_DRIVER=mysql + +MARIADB_TAG=11.8-3.34.1 +VALKEY_TAG=9.0-1.5.0 +VARNISH_TAG=6.0-4.23.2 +SOLR_TAG=9-5.4.0 + +NGINX_VHOST_PRESET=drupal11 +NGINX_TAG=1.29-5.46.1 +DRUPAL_STABILITY_TAG=4.91.1 +ZOOKEEPER_TAG=3.8 \ No newline at end of file diff --git a/tests/11/compose.yml b/tests/11/compose.yml new file mode 100644 index 0000000000..69ff39cd43 --- /dev/null +++ b/tests/11/compose.yml @@ -0,0 +1,78 @@ +services: + mariadb: + image: wodby/mariadb:$MARIADB_TAG + environment: + MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD + MYSQL_DATABASE: $DB_NAME + MYSQL_USER: $DB_USER + MYSQL_PASSWORD: $DB_PASSWORD + + php: + image: "wodby/drupal:11-${PHP_VER}-${DRUPAL_STABILITY_TAG}" + environment: + # To skip auto init. + WODBY_APP_NAME: drupal + DEBUG: 1 + DRUPAL_VERSION: 11 + DB_HOST: $DB_HOST + DB_NAME: $DB_NAME + DB_USER: $DB_USER + DB_PASSWORD: $DB_PASSWORD + DB_DRIVER: $DB_DRIVER + PHP_SENDMAIL_PATH: '/bin/true' + COLUMNS: 80 + PHP_FPM_USER: wodby + PHP_FPM_GROUP: wodby + COMPOSER_MEMORY_LIMIT: -1 + PHP_ERROR_REPORTING: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED + volumes: + - codebase:/var/www/html + - ./tests.sh:/usr/local/bin/tests.sh + - ./test.settings.php:/var/www/html/web/sites/default/test.settings.php + - ./varnish-purger.yml:/var/www/html/varnish-purger.yml + - ./search_api.server.solr.yml:/var/www/html/solr/search_api.server.solr.yml + + nginx: + image: wodby/nginx:$NGINX_TAG + environment: + NGINX_STATIC_OPEN_FILE_CACHE: "off" + NGINX_BACKEND_HOST: php + NGINX_SERVER_ROOT: /var/www/html/web + NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET + volumes: + - codebase:/var/www/html + depends_on: + - php + + varnish: + image: wodby/varnish:$VARNISH_TAG + depends_on: + - nginx + environment: + VARNISH_SECRET: secret + VARNISH_BACKEND_HOST: nginx + VARNISH_BACKEND_PORT: 80 + VARNISH_CONFIG_PRESET: drupal + VARNISH_PURGE_EXTERNAL_REQUEST_HEADER: X-Real-IP + + valkey: + image: wodby/valkey:$VALKEY_TAG + environment: + VALKEY_PASSWORD: bad-password + + solr: + image: wodby/solr:$SOLR_TAG + environment: + ZK_HOST: zookeeper:2181 + depends_on: + - zookeeper + + zookeeper: + image: zookeeper:$ZOOKEEPER_TAG + environment: + ZOO_MY_ID: 1 + ZOO_SERVERS: server.1=zookeeper:2888:3888;2181 + ZOO_4LW_COMMANDS_WHITELIST: mntr, conf, ruok + +volumes: + codebase: diff --git a/tests/11/run.sh b/tests/11/run.sh new file mode 100755 index 0000000000..c21bd03e79 --- /dev/null +++ b/tests/11/run.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e + +if [[ -n "${DEBUG}" ]]; then + set -x +fi + +docker compose up -d +docker compose exec -T mariadb make check-ready -f /usr/local/bin/actions.mk max_try=12 wait_seconds=5 +docker compose exec -T solr make check-ready -f /usr/local/bin/actions.mk max_try=12 wait_seconds=3 +docker compose exec -T solr make init -f /usr/local/bin/actions.mk +docker compose exec -T --user=0 php apk add --update jq +docker compose exec -T --user=0 php chown -R wodby:wodby /var/www/html +docker compose exec -T php tests.sh +docker compose down diff --git a/tests/11/search_api.server.solr.yml b/tests/11/search_api.server.solr.yml new file mode 100644 index 0000000000..f735ed6552 --- /dev/null +++ b/tests/11/search_api.server.solr.yml @@ -0,0 +1,77 @@ +uuid: ddc2786c-c601-4e6c-a625-b8ce51768ea3 +langcode: en +status: true +dependencies: + config: + - search_api_solr.solr_cache.cache_document_default_7_0_0 + - search_api_solr.solr_cache.cache_fieldvalue_default_7_0_0 + - search_api_solr.solr_cache.cache_filter_default_7_0_0 + - search_api_solr.solr_cache.cache_persegfilter_default_7_0_0 + - search_api_solr.solr_cache.cache_queryresult_default_7_0_0 + - search_api_solr.solr_field_type.text_edge_und_7_0_0 + - search_api_solr.solr_field_type.text_edgestring_und_6_0_0 + - search_api_solr.solr_field_type.text_en_7_0_0 + - search_api_solr.solr_field_type.text_ngram_und_7_0_0 + - search_api_solr.solr_field_type.text_ngramstring_und_6_0_0 + - search_api_solr.solr_field_type.text_phonetic_en_7_0_0 + - search_api_solr.solr_field_type.text_phonetic_und_7_0_0 + - search_api_solr.solr_field_type.text_und_7_0_0 + - search_api_solr.solr_request_dispatcher.request_dispatcher_httpcachingnever_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_autocomplete_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_extract_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_mlt_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_select_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_spell_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_suggest_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_tvrh_default_7_0_0 + module: + - search_api_solr +id: solr +name: solr +description: '' +backend: search_api_solr +backend_config: + retrieve_data: false + highlight_data: false + site_hash: false + server_prefix: '' + domain: generic + environment: default + connector: solr_cloud_basic_auth + connector_config: + scheme: http + host: solr + port: 8983 + path: / + core: default + timeout: 5 + index_timeout: 5 + optimize_timeout: 10 + finalize_timeout: 30 + skip_schema_check: false + solr_version: '' + http_method: AUTO + commit_within: 1000 + jmx: false + jts: false + solr_install_dir: '' + username: solr + password: SolrRocks + checkpoints_collection: '' + stats_cache: org.apache.solr.search.stats.LRUStatsCache + distrib: true + context: solr + optimize: false + fallback_multiple: false + disabled_field_types: { } + disabled_caches: { } + disabled_request_handlers: + - request_handler_elevate_default_7_0_0 + - request_handler_replicationmaster_default_7_0_0 + - request_handler_replicationslave_default_7_0_0 + disabled_request_dispatchers: + - request_dispatcher_httpcaching_default_7_0_0 + rows: 10 + index_single_documents_fallback_count: 10 + index_empty_text_fields: false + suppress_missing_languages: false diff --git a/tests/11/test.settings.php b/tests/11/test.settings.php new file mode 100644 index 0000000000..a5bca0e1d7 --- /dev/null +++ b/tests/11/test.settings.php @@ -0,0 +1,21 @@ +>"${PWD}/sites/default/settings.php" + +## Enable redis +check_rq "Redis" "Connected" + +check_rq "Trusted Host Settings" "Enabled" + +# Import solr server +drush cim --source=/var/www/html/solr --partial -y +drush solr-upload-conf solr +drush sapi-sl | grep -q enabled + +## Test varnish cache and purge +drush ppadd varnish +drush cr + +## Workaround for varnish purger import https://www.drupal.org/node/2856221 +PURGER_ID=$(drush ppls --format=json | jq -r "keys[0]") + +mkdir -p /var/www/html/varnish +# We copy mounted file because we can't edit mounted file (resource busy error). +cp /var/www/html/varnish-purger.yml /var/www/html/varnish/purger.yml +sed -i "s/PLUGIN_ID/${PURGER_ID}/g" /var/www/html/varnish/purger.yml +mv /var/www/html/varnish/purger.yml "/var/www/html/varnish/varnish_purger.settings.${PURGER_ID}.yml" +drush -y cim --source=/var/www/html/varnish --partial +drush -y config-set system.performance cache.page.max_age 43200 + +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: MISS" +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: HIT" + +drush cc render +drush pqw + +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: MISS" +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: HIT" diff --git a/tests/11/varnish-purger.yml b/tests/11/varnish-purger.yml new file mode 100644 index 0000000000..9f763d9ee5 --- /dev/null +++ b/tests/11/varnish-purger.yml @@ -0,0 +1,25 @@ +uuid: 91faa2b9-fd7a-4419-8dae-fc5a91b782b6 +langcode: en +status: true +dependencies: { } +id: PLUGIN_ID +name: 'Varnish 4.1' +invalidationtype: tag +hostname: varnish +port: 6081 +path: / +request_method: BAN +scheme: http +verify: '1' +headers: + - + field: Cache-Tags + value: '[invalidation:expression]' +body: null +body_content_type: null +runtime_measurement: true +timeout: !!float 1 +connect_timeout: !!float 1 +cooldown_time: !!float 0 +max_requests: 100 +http_errors: true diff --git a/tests/cms/.env b/tests/cms/.env new file mode 100644 index 0000000000..38f944ea55 --- /dev/null +++ b/tests/cms/.env @@ -0,0 +1,16 @@ +DB_NAME=drupal +DB_USER=drupal +DB_PASSWORD=drupal +DB_ROOT_PASSWORD=password +DB_HOST=mariadb +DB_DRIVER=mysql + +MARIADB_TAG=11.8-3.34.1 +VALKEY_TAG=9.0-1.5.0 +VARNISH_TAG=6.0-4.23.2 +SOLR_TAG=9-5.4.0 + +NGINX_VHOST_PRESET=drupal11 +NGINX_TAG=1.29-5.46.1 +DRUPAL_CMS_STABILITY_TAG=0.1.0 +ZOOKEEPER_TAG=3.8 \ No newline at end of file diff --git a/tests/cms/compose.yml b/tests/cms/compose.yml new file mode 100644 index 0000000000..455b48685e --- /dev/null +++ b/tests/cms/compose.yml @@ -0,0 +1,78 @@ +services: + mariadb: + image: wodby/mariadb:$MARIADB_TAG + environment: + MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD + MYSQL_DATABASE: $DB_NAME + MYSQL_USER: $DB_USER + MYSQL_PASSWORD: $DB_PASSWORD + + php: + image: "wodby/drupal-cms:1-${DRUPAL_CMS_STABILITY_TAG}" + environment: + # To skip auto init. + WODBY_APP_NAME: drupal + DEBUG: 1 + DRUPAL_VERSION: 11 + DB_HOST: $DB_HOST + DB_NAME: $DB_NAME + DB_USER: $DB_USER + DB_PASSWORD: $DB_PASSWORD + DB_DRIVER: $DB_DRIVER + PHP_SENDMAIL_PATH: '/bin/true' + COLUMNS: 80 + PHP_FPM_USER: wodby + PHP_FPM_GROUP: wodby + COMPOSER_MEMORY_LIMIT: -1 + PHP_ERROR_REPORTING: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED + volumes: + - codebase:/var/www/html + - ./tests.sh:/usr/local/bin/tests.sh + - ./test.settings.php:/var/www/html/web/sites/default/test.settings.php + - ./varnish-purger.yml:/var/www/html/varnish-purger.yml + - ./search_api.server.solr.yml:/var/www/html/solr/search_api.server.solr.yml + + nginx: + image: wodby/nginx:$NGINX_TAG + environment: + NGINX_STATIC_OPEN_FILE_CACHE: "off" + NGINX_BACKEND_HOST: php + NGINX_SERVER_ROOT: /var/www/html/web + NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET + volumes: + - codebase:/var/www/html + depends_on: + - php + + varnish: + image: wodby/varnish:$VARNISH_TAG + depends_on: + - nginx + environment: + VARNISH_SECRET: secret + VARNISH_BACKEND_HOST: nginx + VARNISH_BACKEND_PORT: 80 + VARNISH_CONFIG_PRESET: drupal + VARNISH_PURGE_EXTERNAL_REQUEST_HEADER: X-Real-IP + + valkey: + image: wodby/valkey:$VALKEY_TAG + environment: + VALKEY_PASSWORD: bad-password + + solr: + image: wodby/solr:$SOLR_TAG + environment: + ZK_HOST: zookeeper:2181 + depends_on: + - zookeeper + + zookeeper: + image: zookeeper:$ZOOKEEPER_TAG + environment: + ZOO_MY_ID: 1 + ZOO_SERVERS: server.1=zookeeper:2888:3888;2181 + ZOO_4LW_COMMANDS_WHITELIST: mntr, conf, ruok + +volumes: + codebase: diff --git a/tests/cms/run.sh b/tests/cms/run.sh new file mode 100755 index 0000000000..c21bd03e79 --- /dev/null +++ b/tests/cms/run.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e + +if [[ -n "${DEBUG}" ]]; then + set -x +fi + +docker compose up -d +docker compose exec -T mariadb make check-ready -f /usr/local/bin/actions.mk max_try=12 wait_seconds=5 +docker compose exec -T solr make check-ready -f /usr/local/bin/actions.mk max_try=12 wait_seconds=3 +docker compose exec -T solr make init -f /usr/local/bin/actions.mk +docker compose exec -T --user=0 php apk add --update jq +docker compose exec -T --user=0 php chown -R wodby:wodby /var/www/html +docker compose exec -T php tests.sh +docker compose down diff --git a/tests/cms/search_api.server.solr.yml b/tests/cms/search_api.server.solr.yml new file mode 100644 index 0000000000..f735ed6552 --- /dev/null +++ b/tests/cms/search_api.server.solr.yml @@ -0,0 +1,77 @@ +uuid: ddc2786c-c601-4e6c-a625-b8ce51768ea3 +langcode: en +status: true +dependencies: + config: + - search_api_solr.solr_cache.cache_document_default_7_0_0 + - search_api_solr.solr_cache.cache_fieldvalue_default_7_0_0 + - search_api_solr.solr_cache.cache_filter_default_7_0_0 + - search_api_solr.solr_cache.cache_persegfilter_default_7_0_0 + - search_api_solr.solr_cache.cache_queryresult_default_7_0_0 + - search_api_solr.solr_field_type.text_edge_und_7_0_0 + - search_api_solr.solr_field_type.text_edgestring_und_6_0_0 + - search_api_solr.solr_field_type.text_en_7_0_0 + - search_api_solr.solr_field_type.text_ngram_und_7_0_0 + - search_api_solr.solr_field_type.text_ngramstring_und_6_0_0 + - search_api_solr.solr_field_type.text_phonetic_en_7_0_0 + - search_api_solr.solr_field_type.text_phonetic_und_7_0_0 + - search_api_solr.solr_field_type.text_und_7_0_0 + - search_api_solr.solr_request_dispatcher.request_dispatcher_httpcachingnever_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_autocomplete_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_extract_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_mlt_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_select_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_spell_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_suggest_default_7_0_0 + - search_api_solr.solr_request_handler.request_handler_tvrh_default_7_0_0 + module: + - search_api_solr +id: solr +name: solr +description: '' +backend: search_api_solr +backend_config: + retrieve_data: false + highlight_data: false + site_hash: false + server_prefix: '' + domain: generic + environment: default + connector: solr_cloud_basic_auth + connector_config: + scheme: http + host: solr + port: 8983 + path: / + core: default + timeout: 5 + index_timeout: 5 + optimize_timeout: 10 + finalize_timeout: 30 + skip_schema_check: false + solr_version: '' + http_method: AUTO + commit_within: 1000 + jmx: false + jts: false + solr_install_dir: '' + username: solr + password: SolrRocks + checkpoints_collection: '' + stats_cache: org.apache.solr.search.stats.LRUStatsCache + distrib: true + context: solr + optimize: false + fallback_multiple: false + disabled_field_types: { } + disabled_caches: { } + disabled_request_handlers: + - request_handler_elevate_default_7_0_0 + - request_handler_replicationmaster_default_7_0_0 + - request_handler_replicationslave_default_7_0_0 + disabled_request_dispatchers: + - request_dispatcher_httpcaching_default_7_0_0 + rows: 10 + index_single_documents_fallback_count: 10 + index_empty_text_fields: false + suppress_missing_languages: false diff --git a/tests/cms/test.settings.php b/tests/cms/test.settings.php new file mode 100644 index 0000000000..a5bca0e1d7 --- /dev/null +++ b/tests/cms/test.settings.php @@ -0,0 +1,21 @@ +>"${PWD}/sites/default/settings.php" + +## Enable redis +check_rq "Redis" "Connected" + +check_rq "Trusted Host Settings" "Enabled" + +# Import solr server +drush cim --source=/var/www/html/solr --partial -y +drush solr-upload-conf solr +drush sapi-sl | grep -q enabled + +## Test varnish cache and purge +drush ppadd varnish +drush cr + +## Workaround for varnish purger import https://www.drupal.org/node/2856221 +PURGER_ID=$(drush ppls --format=json | jq -r "keys[0]") + +mkdir -p /var/www/html/varnish +# We copy mounted file because we can't edit mounted file (resource busy error). +cp /var/www/html/varnish-purger.yml /var/www/html/varnish/purger.yml +sed -i "s/PLUGIN_ID/${PURGER_ID}/g" /var/www/html/varnish/purger.yml +mv /var/www/html/varnish/purger.yml "/var/www/html/varnish/varnish_purger.settings.${PURGER_ID}.yml" +drush -y cim --source=/var/www/html/varnish --partial +drush -y config-set system.performance cache.page.max_age 43200 + +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: MISS" +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: HIT" + +drush cc render +drush pqw + +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: MISS" +curl -Is -H 'Host: drupal.localhost' varnish:6081 | grep -q "X-VC-Cache: HIT" diff --git a/tests/cms/varnish-purger.yml b/tests/cms/varnish-purger.yml new file mode 100644 index 0000000000..9f763d9ee5 --- /dev/null +++ b/tests/cms/varnish-purger.yml @@ -0,0 +1,25 @@ +uuid: 91faa2b9-fd7a-4419-8dae-fc5a91b782b6 +langcode: en +status: true +dependencies: { } +id: PLUGIN_ID +name: 'Varnish 4.1' +invalidationtype: tag +hostname: varnish +port: 6081 +path: / +request_method: BAN +scheme: http +verify: '1' +headers: + - + field: Cache-Tags + value: '[invalidation:expression]' +body: null +body_content_type: null +runtime_measurement: true +timeout: !!float 1 +connect_timeout: !!float 1 +cooldown_time: !!float 0 +max_requests: 100 +http_errors: true diff --git a/traefik.yml b/traefik.yml new file mode 100644 index 0000000000..6c563cc5d3 --- /dev/null +++ b/traefik.yml @@ -0,0 +1,21 @@ +services: + traefik: + image: traefik:v2.0 + command: --api.insecure=true --providers.docker + networks: + - project1 + - project2 + ports: + - '80:80' + - '8080:8080' + volumes: + - /var/run/docker.sock:/var/run/docker.sock + +networks: + project1: + external: true + name: project1-dir_default + project2: + external: true + name: project2-dir_default +