├── .gitignore ├── README.md ├── docker-compose.mac.yml ├── docker-compose.nix.yml ├── docker-compose.yml ├── docker-sync.yml ├── docker ├── env-example ├── new-site-install.yml └── settings.docker.local.php ├── drush ├── README.md ├── drushrc.php ├── policy.drush.inc └── site-aliases │ └── docker.aliases.drushrc.php ├── files ├── .gitignore ├── private │ └── .gitignore └── public │ └── .gitignore └── mariadb-init ├── .gitignore ├── README.md └── create-db.sql /.gitignore: -------------------------------------------------------------------------------- 1 | # User Generated Content # 2 | ########################## 3 | web/files 4 | web/sites/*/files 5 | web/sites/*/private 6 | web/sites/*/settings.local.php 7 | private/* 8 | docker-compose.override.yml 9 | 10 | # Compiled source # 11 | ################### 12 | *.com 13 | *.class 14 | *.dll 15 | *.exe 16 | *.o 17 | *.so 18 | 19 | # Packages # 20 | ############ 21 | # It's better to unpack these files and commit the raw source, git has its own 22 | # built in compression methods 23 | *.7z 24 | *.dmg 25 | *.gz 26 | *.iso 27 | *.jar 28 | *.rar 29 | *.tar 30 | *.zip 31 | 32 | # Logs and databases # 33 | ###################### 34 | *.log 35 | *.sql 36 | *.sqlite 37 | 38 | # OS generated files # 39 | ###################### 40 | .DS_Store* 41 | ehthumbs.db 42 | Icon\? 43 | Thumbs.db 44 | 45 | # IDEs # 46 | ######## 47 | .idea 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Drupal Boilerplate 2 | 3 | Boilerplate to create new Drupal 8 projects that can be managed locally in Docker containers. It uses [Docker4Drupal](https://github.com/wodby/docker4drupal) for the Docker configuration. You can also use [Drupal Composer Project](https://github.com/drupal-composer/drupal-project) to create a Drupal installation from scratch. 4 | 5 | ## Prerequisites 6 | 7 | 1. [Docker](https://docs.docker.com/engine/installation/) (for MacOS, Windows, or Linux) 8 | 2. [Docker-Compose](https://docs.docker.com/compose/install/) (only required for Linux, already included in Docker for MacOSX and Windows) 9 | 3. [Docker-Sync](http://docker-sync.io) (not necessary for Linux, improves file syncing performance on MacOSX and Windows) 10 | 11 | ## Installation 12 | 13 | 1. Fork this repository to create a new project. 14 | 2. Copy `/docker/env-example` to `.env` to set an environment value for `COMPOSE_PROJECT_NAME`. This will be the machine name for the project, and should be alphanumeric. This name will be used as the prefix for all the Docker containers, so it should be unique among all containers that might be running on the same host. If the project name is `drupal8`, the php container name will be `drupal8_php_1`. The project name is also used in the container urls. For the same `drupal8` project name, the browser path will be `http://drupal8.docker.localhost:8000`. 15 | 3. Add the Drupal codebase, placing the Drupal root in the `/web` subdirectory of this repository. 16 | 3. Add the following code to the bottom of settings.php: 17 | 18 | ``` 19 | // Add settings for Docker4Drupal containers. 20 | if (!empty($_SERVER['WODBY_DIR_FILES'])) { 21 | include '/var/www/html/docker/settings.docker.local.php'; 22 | } 23 | ``` 24 | 4. Add a database and files, depending on your needs. See the sections below to `Mount an Existing Database`, `Mount Existing Files`, or `Install Vanilla Drupal 8 Site` using composer and Drupal Console. 25 | 26 | 27 | ## Docker-Compose Overrides 28 | Docker-compose is configured differently depending on the capabilities of the host operating system. When sharing a repository we want to keep the host-specific configuration out of the main `docker-compose` file, in particular the `volumes` mapping, since that will vary between dev/stage/prod and local development. 29 | 30 | You can create files that contain [docker-compose overrides](https://docs.docker.com/compose/extends/) to `docker-compose.yml`. You can use this feature to set up host-specific overrides. The override files don't need to be complete `docker-compose` files, they only need to contain the override values. Docker can merge the contents of multiple files together when you execute `docker-compose up`, if you identify the names of the files you want to merge. For instance, to run this on a Mac you could do: 31 | 32 | ``` 33 | docker-compose -f docker-compose.yml -f docker-compose.mac.yml up -d 34 | ``` 35 | 36 | 37 | To make things even easier, you can just create a copy of the override file you want to use and name the copy `docker-compose.override.yml`. If you do that you can simplify the command to the following, since Docker Comose's default behavior is to merge a file called `docker-compose.yml` with a file called `docker-compose.override.yml`: 38 | 39 | ``` 40 | docker-compose up -d 41 | ``` 42 | 43 | 44 | See information below on how to adjust configuration for `SSH`, `HTTPS/SSL`, or `Docker-Sync for MacOSX or Windows`. 45 | 46 | 47 | ## Host Operations 48 | Once you have prepared the database and files from the directions below, use the following commands to manage the containers. All are run from the root of the docker repository on the host machine. 49 | 50 | The first time you `start` the containers, it may take several minutes. After that they will rely on cached copies of the images and should start very quickly. The containers will start up in the background so it's hard to tell when they're ready. You can tail the logs to see what's happening. When you see `KEEPALIVE` entries from `mailhog` the containers are ready. 51 | 52 | - To launch the Docker containers on a Mac, type 53 | 54 | ``` 55 | docker-compose up -d 56 | ``` 57 | 58 | Add and adjust the override file names to that command, if necessary, as explained above. If you leave out the `-d` you'll have to keep that window open as long as you want the containers to live. Closing the window or doing `ctl-c` will stop the containers. Adding the `-d` means it will start in detached mode, allowing you to continue to use that terminal window while the containers run in the background. 59 | - Type `docker-compose stop` to pause the containers without destroying the data. 60 | - Type `docker-compose down -v` to completely tear down the Docker containers and their volumes. 61 | - Type `docker-compose logs -f` to view and follow the log entries from the containers. To stop viewing the logs, use `ctl-c` to exit out of the logs (this will not stop the containers, just stop following the logs). 62 | - To communicate from one container to another, treat the name of the service as if it was the IP address of a remote server. For instance, to get into the mariadb database from the php container, set the host as `mariadb`, i.e.: 63 | 64 | ``` 65 | mysql -udrupal -pdrupal -hmariadb 66 | ``` 67 | 68 | ## Container Operations 69 | 70 | Move into the container from the host using the `docker exec` command, using the project name that was added to `.env`, for instance if `COMPOSE_PROJECT_NAME=drupal8`: 71 | 72 | ``` 73 | docker exec -it drupal8_php_1 /bin/bash 74 | ``` 75 | To return to the host from the container, just type `exit`. 76 | 77 | You will be using the `root` user inside the container, so should have permissions to do anything. The code in your git repository can be found at `/var/www/html` in the container. Drupal's docroot should be located at `/var/www/html/web`, using the Drupal-Project pattern. Try the following inside the container to see that the containers were mounted successfully: 78 | 79 | ``` 80 | cd web 81 | drush st 82 | ``` 83 | 84 | To view the site in a browser, navigate to the following url, replacing `[COMPOSE_PROJECT_NAME]` with the project name you put in the `.env` file. With some browsers and operating systems any path ending in `localhost` will work automatically, otherwise you may need update your `hosts` file so your browser will know it's a local url. For instance, if `COMPOSE_PROJECT_NAME=drupal8`, the browser url would be: 85 | 86 | ``` 87 | http://drupal8.docker.localhost:8000 88 | ``` 89 | 90 | ## Docker-Sync for Mac OSX and Windows 91 | The solution to file performance problems on Mac OSX and Windows is to use [Docker-Sync](http://docker-sync.io). To adjust the repository for Docker-Sync, do the following: 92 | 93 | 1. Install [Docker-Sync](http://docker-sync.io). 94 | 2. Use the file `/docker-compose.mac.yml` when running `docker-compose up`, or copy it to `docker-compose.override.yml`. 95 | 3. Run `docker-sync` before starting or after stopping: 96 | - Execute `docker-sync start` before running `docker-compose up`. 97 | - Execute `docker-sync stop` after running `docker-compose stop`. 98 | - Execute `docker-sync clean` after running `docker-compose down`. 99 | 100 | ## Mount an Existing Database 101 | 102 | There are a couple ways to populate the database inside the container. 103 | 104 | - The folder `/mariadb-init` will be checked when the container is spun up. If there are any SQL files in that folder, they will be executed at that time. The default repository contains a SQL file to create an empty Drupal database. Alternately, a SQL dump file could be added to that folder to populate the database. 105 | - If the Drush alias file has been updated with values from a source site, and SSH credentials have been set up correctly in the docker-compose file, the container can be populated using drush inside the container: `drush sql-sync @docker.source @docker.container` 106 | 107 | 108 | ## Mount Existing Files 109 | 110 | There are a couple ways to populate the files inside the container: 111 | 112 | - Copy public files directly into `/web/sites/default/files` and private files into `/files/private`. 113 | - Copy public files into `/files/public`, and private files into `/files/private`, then create a relative symlink for `sites/default/files`. The relative symlink is necessary since the absolute path will be different inside the container. For instance, 114 | 115 | 116 | ``` 117 | cd web/sites/default 118 | ln -s ../../../files/public files 119 | ``` 120 | 121 | - If the Drush alias file has been updated with values from a source site, and SSH credentials have been set up correctly in the docker-compose file, don't copy the files in at all, just create the files directory, then wait until the container has been started and move into it and populate the files with: 122 | 123 | ``` 124 | drush rsync @docker.source:%files/ @docker.container:%files` 125 | ``` 126 | 127 | ## Configure SSH 128 | 129 | To communicate with servers outside the Docker containers, for instance to be able to use `drush sql-sync`, the Docker-compose file passes ssh credentials and keys through to the container as a volume, `- ~/.ssh:/root/.ssh`. You should have a ssh config file in your home directory, `./ssh/config`, that identifies the user name that matches your ssh keys. This will allow you to ssh as yourself, instead of the root user, from inside the container. For example, `/ssh/config` might look like: 130 | 131 | ``` 132 | Host example.com 133 | User karen 134 | ``` 135 | 136 | If that is not the correct location for your SSH credentials, override these values in a custom `docker-compose` override file. 137 | 138 | ## Using Drush in the Container 139 | 140 | Drush will be available inside the container. Drush files can be used to provide localized values applicable to the containerized site: 141 | 142 | - The file `/drush/site-aliases/docker.aliases.drushrc.php`creates drush aliases `@docker.container` and `@docker.source`. The `container` values should be correct. Update the values in `source` to match an external site, if any, to make it easy to copy files and the database to and from that location. 143 | - The file `/drush/drushrc.php` uses the drush aliases to create simple aliases to copy files and database from the source by executing `drush syncfiles`, `drush syncprivate`, and `drush syncdb`. 144 | 145 | 146 | ## Configure HTTPS/SSL 147 | You may want the containers to use SSL, either to test SSL operations or for consistency with the production urls. 148 | 149 | - Set up a self-signed SSL certificate for use in local HTTPS containers. On a Mac, do the following, other operating systems may need to be handled differently. All containers using a domain like `*.docker.localhost` will be able share this cert. The cert is be stored on the host rather than in the container, so this only needs to be done once: 150 | 151 | ``` 152 | ## Make a directory for the cert. 153 | mk dir ~/ssl/certs 154 | 155 | # Create a wildcard cert. 156 | openssl req \ 157 | -newkey rsa:2048 \ 158 | -x509 \ 159 | -nodes \ 160 | -keyout ~/ssl/certs/key.pem \ 161 | -new \ 162 | -out ~/ssl/certs/cert.pem \ 163 | -subj /CN=*.docker.localhost \ 164 | -reqexts SAN \ 165 | -extensions SAN \ 166 | -config <(cat /System/Library/OpenSSL/openssl.cnf \ 167 | <(printf '[SAN]\nsubjectAltName=DNS:*.docker.localhost')) \ 168 | -sha256 \ 169 | -days 720 170 | 171 | # Add the cert to Mac's keychain. 172 | sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/ssl/certs/cert.pem 173 | 174 | ``` 175 | 176 | - Uncomment the SSL configuration in `docker-compose.mac.yml` or `docker-compose.nix.yml`. 177 | - Adjust all container urls to use `HTTPS` instead of `HTTP`, and the port `4443` instead of `8000`, for instance: 178 | - HTTP: `http://drupal8.docker.localhost:8000` 179 | - HTTPS: `https://drupal8.docker.localhost:4443` 180 | 181 | 182 | ## Install a Vanilla Drupal 8 Site 183 | 184 | If you don't already have a codebase, you can pull down a vanilla Drupal site using [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx). Navigate to the top level of this repository, add a `composer.json` file that requires the desired modules, and run the following command. No parameters are necessary since it will build information from the `composer.json` file located there: 185 | 186 | `composer create-project` 187 | 188 | Edit the file `/docker/new-site-install.yml`. It is used only if you want to install a vanilla site from scratch. Drupal Console can build a site from that file. 189 | 190 | Start the containers, then enter the php container, cd to the `web` directory inside the container, and install a new site with Drupal Console: 191 | 192 | `/var/www/html/vendor/bin/drupal chain --file=/var/www/html/docker/new-site-install.yml` 193 | 194 | The current version of Drupal Console has a bug that generates a `Drupal Finder` error after the site is installed, but the installation should work fine. 195 | 196 | -------------------------------------------------------------------------------- /docker-compose.mac.yml: -------------------------------------------------------------------------------- 1 | # Use Docker-Sync for Mac OSX performance 2 | # See README.md for more information. 3 | 4 | version: "2" 5 | 6 | services: 7 | mariadb: 8 | volumes: 9 | # See README.md in /docker/mariadb-init. 10 | - ./mariadb-init:/docker-entrypoint-initdb.d 11 | 12 | php: 13 | volumes: 14 | - docker-sync:/var/www/html 15 | - ~/.ssh:/root/.ssh 16 | 17 | nginx: 18 | volumes: 19 | - docker-sync:/var/www/html 20 | 21 | ## Uncomment the following to enable HTTPS/ssl 22 | # traefik: 23 | # command: -c /dev/null --web --docker --logLevel=INFO --defaultEntryPoints='https' --entryPoints="Name:https Address::443 TLS:/certs/cert.pem,/certs/key.pem" --entryPoints="Name:http Address::80 Redirect.EntryPoint:https" 24 | # ports: 25 | # - '4443:443' 26 | # volumes: 27 | # - ~/ssl/certs:/certs/ 28 | 29 | volumes: 30 | docker-sync: 31 | external: true 32 | -------------------------------------------------------------------------------- /docker-compose.nix.yml: -------------------------------------------------------------------------------- 1 | # Example basic docker-compose.override file. 2 | # See README.md for more information. 3 | 4 | version: "2" 5 | 6 | services: 7 | 8 | mariadb: 9 | volumes: 10 | # See README.md in /docker/mariadb-init. 11 | - ./mariadb-init:/docker-entrypoint-initdb.d 12 | php: 13 | volumes: 14 | - codebase:/var/www/html 15 | - ~/.ssh:/root/.ssh 16 | 17 | nginx: 18 | volumes: 19 | - codebase:/var/www/html 20 | 21 | ## Uncomment the following to enable HTTPS/ssl 22 | # traefik: 23 | # command: -c /dev/null --web --docker --logLevel=INFO --defaultEntryPoints='https' --entryPoints="Name:https Address::443 TLS:/certs/cert.pem,/certs/key.pem" --entryPoints="Name:http Address::80 Redirect.EntryPoint:https" 24 | # ports: 25 | # - '4443:443' 26 | # volumes: 27 | # - ~/ssl/certs:/certs/ 28 | 29 | volumes: 30 | codebase: 31 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # Slightly adapted from docker4drupal. 2 | # See https://docker4drupal.readthedocs.io/en/latest/ 3 | version: "2" 4 | 5 | services: 6 | mariadb: 7 | image: wodby/mariadb:10.1-2.3.3 8 | environment: 9 | # See all available mariadb variables at https://github.com/wodby/mariadb. 10 | MYSQL_ROOT_PASSWORD: password 11 | MYSQL_DATABASE: drupal 12 | MYSQL_USER: drupal 13 | MYSQL_PASSWORD: drupal 14 | 15 | php: 16 | # 2. Images without Drupal – wodby/drupal-php:[PHP_VERSION]-[STABILITY_TAG]. 17 | image: wodby/drupal-php:7.1-2.4.2 18 | # image: wodby/drupal-php:7.0-2.4.2 19 | # image: wodby/drupal-php:5.6-2.4.2 20 | # image: wodby/drupal-php:5.3-2.4.2 21 | # Pass environment variables to the container. 22 | environment: 23 | # See all available PHP variables at https://github.com/wodby/php. 24 | DB_HOST: mariadb 25 | DB_USER: drupal 26 | DB_PASSWORD: drupal 27 | DB_NAME: drupal 28 | DB_DRIVER: mysql 29 | COMPOSE_PROJECT_NAME: "${COMPOSE_PROJECT_NAME}" 30 | PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 31 | PHP_TIMEZONE: America/New_York 32 | # PHP_XDEBUG: 1 33 | # PHP_XDEBUG_DEFAULT_ENABLE: 1 34 | # PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow 35 | # PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254' 36 | 37 | nginx: 38 | # wodby/drupal-nginx:[DRUPAL_VERSION]-[NGINX_VERSION]-[STABILITY_TAG]. 39 | image: wodby/drupal-nginx:8-1.13-2.4.0 40 | # image: wodby/drupal-nginx:7-1.13-2.4.0 41 | # image: wodby/drupal-nginx:6-1.13-2.4.0 42 | # image: wodby/drupal-nginx:8-1.12-2.4.0 43 | # image: wodby/drupal-nginx:7-1.12-2.4.0 44 | # image: wodby/drupal-nginx:6-1.12-2.4.0 45 | depends_on: 46 | - php 47 | environment: 48 | # See all available NGINX variables at https://github.com/wodby/php. 49 | NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off" 50 | NGINX_ERROR_LOG_LEVEL: debug 51 | NGINX_BACKEND_HOST: php 52 | NGINX_SERVER_ROOT: /var/www/html/web 53 | labels: 54 | - "traefik.backend=nginx" 55 | - "traefik.port=80" 56 | - "traefik.frontend.rule=Host:${COMPOSE_PROJECT_NAME}.docker.localhost" 57 | 58 | # apache: 59 | # image: wodby/drupal-apache:2.4-1.0.0 60 | # depends_on: 61 | # - php 62 | # environment: 63 | # APACHE_LOG_LEVEL: debug 64 | # APACHE_BACKEND_HOST: php 65 | # APACHE_SERVER_ROOT: /var/www/html/web 66 | # volumes: 67 | # - codebase:/var/www/html/web 68 | # labels: 69 | # - 'traefik.backend=apache' 70 | # - 'traefik.port=80' 71 | # - "traefik.frontend.rule=Host:${COMPOSE_PROJECT_NAME}.docker.localhost" 72 | 73 | # varnish: 74 | # image: wodby/drupal-varnish:4.1-2.1.2 75 | # depends_on: 76 | # - nginx 77 | # environment: 78 | # VARNISH_SECRET: secret 79 | # VARNISH_BACKEND_HOST: nginx 80 | # VARNISH_BACKEND_PORT: 80 81 | # labels: 82 | # - 'traefik.backend=varnish' 83 | # - 'traefik.port=6081' 84 | # - "traefik.frontend.rule=Host:varnish.${COMPOSE_PROJECT_NAME}.docker.localhost" 85 | 86 | # redis: 87 | # image: wodby/redis:3.2-2.1.1 88 | 89 | # adminer: 90 | # image: wodby/adminer:4.3-1.1.0 91 | # environment: 92 | # ADMINER_SALT: adminer-salt 93 | # labels: 94 | # - 'traefik.backend=adminer' 95 | # - 'traefik.port=9000' 96 | # - "traefik.frontend.rule=Host:adminer.${COMPOSE_PROJECT_NAME}.docker.localhost" 97 | 98 | # pma: 99 | # image: phpmyadmin/phpmyadmin 100 | # environment: 101 | # PMA_HOST: mariadb 102 | # PMA_USER: drupal 103 | # PMA_PASSWORD: drupal 104 | # PHP_UPLOAD_MAX_FILESIZE: 1G 105 | # PHP_MAX_INPUT_VARS: 1G 106 | # labels: 107 | # - 'traefik.backend=pma' 108 | # - 'traefik.port=80' 109 | # - "traefik.frontend.rule=Host:pma.${COMPOSE_PROJECT_NAME}.docker.localhost" 110 | 111 | # solr: 112 | ## wodby/drupal-solr:[DRUPAL_VERSION]-[SOLR_VERSION]-[STABILITY_TAG]. 113 | # image: wodby/drupal-solr:8-6.4-2.1.0 114 | ## image: wodby/drupal-solr:8-6.3-2.1.0 115 | ## image: wodby/drupal-solr:8-5.5-2.1.0 116 | ## image: wodby/drupal-solr:7-5.4-2.1.0 117 | # environment: 118 | # SOLR_HEAP: 1024m 119 | # labels: 120 | # - 'traefik.backend=solr' 121 | # - 'traefik.port=8983' 122 | # - "traefik.frontend.rule=Host:solr.${COMPOSE_PROJECT_NAME}.docker.localhost" 123 | 124 | mailhog: 125 | image: mailhog/mailhog 126 | labels: 127 | - 'traefik.backend=mailhog' 128 | - 'traefik.port=8025' 129 | - "traefik.frontend.rule=Host:mailhog.${COMPOSE_PROJECT_NAME}.docker.localhost" 130 | 131 | # nodejs: 132 | # image: wodby/drupal-node:1.0-1.0.0 133 | # environment: 134 | # NODE_SERVICE_KEY: node-service-key 135 | # labels: 136 | # - 'traefik.backend=nodejs' 137 | # - 'traefik.port=8080' 138 | # - "traefik.frontend.rule=Host:nodejs.${COMPOSE_PROJECT_NAME}.docker.localhost" 139 | # volumes: 140 | # - ./path/to/your/single-page-app:/app 141 | # command: sh -c 'npm install && npm run start' 142 | 143 | # node: 144 | # image: node:alpine 145 | # working_dir: /app 146 | # labels: 147 | # - 'traefik.backend=node' 148 | # - 'traefik.port=3000' 149 | # - "traefik.frontend.rule=Host:front.${COMPOSE_PROJECT_NAME}.docker.localhost" 150 | # expose: 151 | # - "3000" 152 | # volumes: 153 | # - ./path/to/your/single-page-app:/app 154 | # command: sh -c 'npm install && npm run start' 155 | 156 | # memcached: 157 | # image: wodby/memcached:1.4-2.0.0 158 | 159 | # rsyslog: 160 | # image: wodby/rsyslog 161 | 162 | # athenapdf: 163 | # image: arachnysdocker/athenapdf-service 164 | # environment: 165 | # WEAVER_AUTH_KEY: weaver-auth-key 166 | # WEAVER_ATHENA_CMD: "athenapdf -S" 167 | # WEAVER_MAX_WORKERS: 10 168 | # WEAVER_MAX_CONVERSION_QUEUE: 50 169 | # WEAVER_WORKER_TIMEOUT: 90 170 | # WEAVER_CONVERSION_FALLBACK: false 171 | 172 | portainer: 173 | image: portainer/portainer 174 | command: --no-auth 175 | volumes: 176 | - /var/run/docker.sock:/var/run/docker.sock 177 | labels: 178 | - 'traefik.backend=portainer' 179 | - 'traefik.port=9000' 180 | - "traefik.frontend.rule=Host:portainer.${COMPOSE_PROJECT_NAME}.docker.localhost" 181 | 182 | traefik: 183 | image: traefik 184 | command: -c /dev/null --web --docker --logLevel=INFO 185 | ports: 186 | - '8000:80' 187 | # - '8080:8080' # Dashboard 188 | volumes: 189 | - /var/run/docker.sock:/var/run/docker.sock 190 | -------------------------------------------------------------------------------- /docker-sync.yml: -------------------------------------------------------------------------------- 1 | # See https://github.com/EugenMayer/docker-sync/blob/master/example/docker-sync.yml 2 | 3 | version: "2" 4 | 5 | syncs: 6 | docker-sync: 7 | src: './' 8 | sync_userid: '82' 9 | sync_excludes: ['private','mariadb-init','.gitignore','.git/','.idea/','.DS_Store'] 10 | volumes: 11 | - docker-sync:/var/www/html 12 | -------------------------------------------------------------------------------- /docker/env-example: -------------------------------------------------------------------------------- 1 | # Set Docker-Compose environment variables here. 2 | # 1) Copy this file to top level as /.env 3 | # 2) Edit the values as appropriate or add other environment variables. 4 | 5 | # Set prefix for the container names, also used for the browser path. 6 | COMPOSE_PROJECT_NAME=drupal8 7 | 8 | # Uncomment below on Windows machines 9 | #COMPOSE_CONVERT_WINDOWS_PATHS=true -------------------------------------------------------------------------------- /docker/new-site-install.yml: -------------------------------------------------------------------------------- 1 | commands: 2 | - command: site:install 3 | options: 4 | langcode: en 5 | db-type: mysql 6 | db-host: mariadb 7 | db-name: drupal 8 | db-user: drupal 9 | db-pass: drupal 10 | db-port: 3306 11 | site-name: 'Drupal 8 site' 12 | site-mail: admin@example.org 13 | account-name: admin 14 | account-mail: admin@example.org 15 | account-pass: admin 16 | arguments: 17 | profile: standard 18 | - command: module:install 19 | arguments: 20 | - token 21 | - metatag 22 | - pathauto 23 | - devel 24 | - kint -------------------------------------------------------------------------------- /docker/settings.docker.local.php: -------------------------------------------------------------------------------- 1 | $wodby['db']['host'], 166 | 'database' => $wodby['db']['name'], 167 | 'username' => $wodby['db']['username'], 168 | 'password' => $wodby['db']['password'], 169 | 'driver' => $wodby['db']['driver'], 170 | ] 171 | ); 172 | } 173 | 174 | $settings['file_public_path'] = "sites/{$wodby['site']}/files"; 175 | $settings['file_private_path'] = $wodby['files_dir'] . '/private'; 176 | $settings['file_temporary_path'] = '/tmp'; 177 | 178 | $config_directories['sync'] = $wodby['files_dir'] . '/config/sync' . $wodby['sync_salt']; 179 | 180 | if (!empty($wodby['hosts'])) { 181 | foreach ($wodby['hosts'] as $host) { 182 | $settings['trusted_host_patterns'][] = '^' . str_replace('.', '\.', $host) . '$'; 183 | } 184 | } 185 | 186 | if (!defined('MAINTENANCE_MODE') || MAINTENANCE_MODE != 'install') { 187 | $site_mods_dir = "sites/{$wodby['site']}/modules"; 188 | $contrib_path = is_dir('modules/contrib') ? 'modules/contrib' : 'modules'; 189 | $contrib_path_site = is_dir("$site_mods_dir/contrib") ? "$site_mods_dir/contrib" : $site_mods_dir; 190 | 191 | $redis_module_path = NULL; 192 | 193 | if (file_exists("$contrib_path/redis")) { 194 | $redis_module_path = "$contrib_path/redis"; 195 | } elseif (file_exists("$contrib_path_site/redis")) { 196 | $redis_module_path = "$contrib_path_site/redis"; 197 | } 198 | 199 | if (!empty($wodby['redis']['host']) && $redis_module_path) { 200 | $settings['redis.connection']['host'] = $wodby['redis']['host']; 201 | $settings['redis.connection']['port'] = $wodby['redis']['port']; 202 | $settings['redis.connection']['password'] = $wodby['redis']['password']; 203 | $settings['redis.connection']['base'] = 0; 204 | $settings['redis.connection']['interface'] = 'PhpRedis'; 205 | $settings['cache']['default'] = 'cache.backend.redis'; 206 | $settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast'; 207 | $settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast'; 208 | $settings['cache']['bins']['config'] = 'cache.backend.chainedfast'; 209 | 210 | $settings['container_yamls'][] = "$redis_module_path/example.services.yml"; 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /drush/README.md: -------------------------------------------------------------------------------- 1 | This directory contains commands, configuration and site aliases for Drush. See https://packagist.org/search/?type=drupal-drush for a directory of Drush commands installable via Composer. 2 | -------------------------------------------------------------------------------- /drush/drushrc.php: -------------------------------------------------------------------------------- 1 | '/var/www/html/web', 11 | 'uri' => $_SERVER['COMPOSE_PROJECT_NAME'] . '.docker.localhost:8000', 12 | 'path-aliases' => array( 13 | '%private' => '/var/www/private/files/private', 14 | ), 15 | ); 16 | 17 | /** 18 | * The source for Docker db and files. 19 | * 20 | * Fill out information here about a site that will serve to supply the db 21 | * and files that will be used in this Docker container. 22 | */ 23 | $aliases['source'] = array ( 24 | 'root' => '/var/www/example.com/web', 25 | 'uri' => 'http://example.com', 26 | 'remote-host' => 'example.com', 27 | 'path-aliases' => array( 28 | '%private' => '/var/www/example.com/private/files', 29 | ), 30 | ); 31 | -------------------------------------------------------------------------------- /files/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !/private/ 4 | !/public/ 5 | !/config/ -------------------------------------------------------------------------------- /files/private/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /files/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /mariadb-init/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | */ 3 | !.gitignore 4 | !README.md 5 | !create-db.sql -------------------------------------------------------------------------------- /mariadb-init/README.md: -------------------------------------------------------------------------------- 1 | # mariadb-init 2 | 3 | This folder is only used when this project is run in a Docker container with Docker-Compose. 4 | 5 | Any .sql files in this directory will be automatically executed by the database when the mariadb container is created. These can include database dumps and/or sql queries or commands needed on startup. 6 | 7 | Once created, data in the container will persist even when the container is stopped or shut down, as long as this volume is not removed. 8 | 9 | The container will afterward ignore the files in this folder. Changing or updating these files later will have no effect on the database in the running container. 10 | 11 | To relaunch the container with new or updated .sql files, shut the container down **and remove its volumes**, then start it again, i.e. 12 | 13 | ``` 14 | docker-compose down -v 15 | docker-compose up 16 | ``` 17 | If there are no .sql files in this folder, no action will be taken when the container is built. 18 | -------------------------------------------------------------------------------- /mariadb-init/create-db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE IF NOT EXISTS drupal DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci; --------------------------------------------------------------------------------