|
1 |
| -# docker-drupal-postgres |
2 |
| -Single Dockerfile build of Drupal with drush and defaulted settings including Postgres |
| 1 | +# Dockerized Drupal with Drush and Postgres |
| 2 | + |
| 3 | +This Dockerfile creates a Docker image for a Drupal application with Drush and Postgres support. It is based on the official Drupal image and includes additional configurations and extensions to support a more robust Drupal development environment. |
| 4 | + |
| 5 | +[](https://github.com/garyGoDev/docker-drupal-postgres/actions/workflows/docker-build.yml) |
| 6 | + |
| 7 | +[DockerHub cloudgrounds/drupal-postgres](https://hub.docker.com/r/cloudgrounds/drupal-postgres) |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- Based on `drupal:10.2.6-php8.2-apache-bookworm` image from [the official Drupal image](https://hub.docker.com/_/drupal/) |
| 12 | +- Includes Drush, a command-line shell and scripting interface for Drupal |
| 13 | +- Configured to use Postgres as the database |
| 14 | +- Includes APCu PHP extension for caching |
| 15 | +- Configures PHP for output buffering |
| 16 | +- Sets up default Drupal settings and file permissions |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +To build the Docker image, navigate to the directory containing the Dockerfile and run: |
| 21 | + |
| 22 | +```bash |
| 23 | +docker build -t your-custom-image:1.0 . |
| 24 | +``` |
| 25 | + |
| 26 | +To run drupal from the image use `docker compose` with the example file |
| 27 | + |
| 28 | +```bash |
| 29 | +HASH_SALT=yourreallyreallylongandrandomhash DRUPAL_ADMIN_PASS=yourfirstsupersafepassword POSTGRES_PASSWORD=yourothersupersafepassword docker-compose up -d |
| 30 | +``` |
| 31 | + |
| 32 | +## Environment Variables |
| 33 | + |
| 34 | +The Dockerfile uses the following environment variables: |
| 35 | + |
| 36 | +- `POSTGRES_DB`: The name of your Postgres database |
| 37 | +- `POSTGRES_USER`: The username for your Postgres database |
| 38 | +- `POSTGRES_PASSWORD`: The password for your Postgres database |
| 39 | +- `POSTGRES_HOST`: The host of your Postgres database |
| 40 | +- `DRUPAL_HASH_SALT`: The hash salt for your Drupal application |
| 41 | +- `DRUPAL_CONFIG_SYNC_DIRECTORY`: The directory for Drupal configuration synchronization files. This should be outside web root. This defaults to `/var/configsync` |
| 42 | +- `DRUPAL_ADMIN_USER`: The username for your Drupal admin account |
| 43 | +- `DRUPAL_ADMIN_PASS`: The password for your Drupal admin account |
| 44 | +- `DRUPAL_ADMIN_EMAIL`: The email for your Drupal admin account |
| 45 | + |
| 46 | +## Volumes |
| 47 | + |
| 48 | +The Dockerfile specifies volumes for the Drupal installation and files directories. This allows you to persist data across container restarts and share data between containers. See the **Volumes** section in the official Drupal image. |
| 49 | + |
| 50 | +## Entrypoint Script |
| 51 | + |
| 52 | +The `entrypoint.sh` script is executed when the Docker container starts. It performs several checks and operations to ensure the Drupal site is properly set up. |
| 53 | + |
| 54 | +### Script Overview |
| 55 | + |
| 56 | +The script performs the following operations: |
| 57 | + |
| 58 | +1. Checks the status of the database connection and Drupal bootstrap using [Drush](https://www.drush.org/). |
| 59 | +2. If the database is not connected and Drupal is not bootstrapped, it installs the Drupal site using the `drush site-install` command. |
| 60 | +3. If the database is connected or Drupal is bootstrapped, it updates the database using the `drush updatedb` command and rebuilds the cache using the `drush cache-rebuild` command. |
| 61 | +4. Finally, it executes the command passed to the `docker run` command. |
| 62 | + |
| 63 | +Environment variables are included above and should be set in your Docker environment or in your `docker-compose.yml` file. |
| 64 | + |
| 65 | +### Drush |
| 66 | + |
| 67 | +[Drush](https://www.drush.org/) is a command-line shell and Unix scripting interface for Drupal. Drush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, executes SQL queries and DB migrations, and misc utilities like run cron or clear cache. |
| 68 | + |
| 69 | +For more information about the Drush commands used in this script, see the following links: |
| 70 | + |
| 71 | +- [drush status](https://www.drush.org/13.x/commands/core_status/) |
| 72 | +- [drush site-install](https://www.drush.org/13.x/commands/site_install/) |
| 73 | +- [drush updatedb](https://www.drush.org/13.x/commands/updatedb/) |
| 74 | +- [drush cache-rebuild](https://www.drush.org/13.x/commands/cache_rebuild/) |
| 75 | + |
| 76 | +## Running Apache |
| 77 | + |
| 78 | +By default, the Docker container will run Apache in the foreground. |
| 79 | + |
| 80 | +## Versions |
| 81 | + |
| 82 | +Versions are based on the run number in the GitHub Actions publication workflow. |
0 commit comments