Skip to content

Commit

Permalink
updated maintaining drupal instructions (#2223)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdentremont authored Apr 19, 2023
1 parent 8c54fd4 commit b3d949a
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions docs/installation/docker-maintain-drupal.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ that are discovered. You should always keep your Drupal site up to date so that
protected against known vulnerabilities. Updating Drupal can be intimidating, but we have
step-by-step instructions to help you do it safely.

## Note on Production Sites

Please note that maintaining Drupal should be done on your development
site. For production sites, you should build an image from the `codebase` folder on your development
machine, and run that image in production. For more information on this, please see the [production install
instructions](https://islandora.github.io/documentation/installation/docker-custom/).

## Running commands

Once you have a `codebase` folder, how do you maintain it and keep it up to date? The quick answer is
"the same way you maintain any Drupal site with Composer and Drush"... with one small caveat. You most
likely do not have PHP or Composer on your machine, and even if you do, you want to make sure you're
using the exact same version that Islandora is using. So to ensure all the versions of things line
using the exact same version that your Docker container is using. So to ensure all the versions of things line
up, we use Docker to execute Drush and Composer from the Drupal container. The general template for
running a command looks like this:
running a command in your Drupal container looks like this:

```
docker-compose exec -T drupal with-contenv bash -lc 'YOUR COMMAND'
```

You can also just shell into the drupal container and run commands as well,
just be aware that if you cycle your container for any reason, you'll lose your
You can also just shell into the Drupal container and run commands as well,
just be aware that if you shut down your container for any reason, you'll lose your
bash history. If you want to shell in to run commands, drop the `-T` and `-lc 'YOUR COMMAND'`
bits.

Expand All @@ -29,14 +36,30 @@ docker-compose exec drupal with-contenv bash

## Updating your Drupal Site

Use composer to update your site's modules and their dependencies. The working directory
of the drupal container is the Drupal root (a.k.a. `codebase`), so you don't need to `cd`
Use Composer to update your site's modules and their dependencies. The working directory
of the Drupal container is the Drupal root (a.k.a. `codebase`), so you don't need to `cd`
into any other directory before running the command. The following command will update
all modules and their dependencies that are not pinned to specific versions.

```
docker-compose exec -T drupal with-contenv bash -lc 'composer update -W'
docker-compose exec -T drupal with-contenv bash -lc "su nginx -s /bin/bash -c 'composer update -W'"
```
Note that we run this command as the nginx user. By default, commands are run as root, which
can cause some ownership issues when running Composer. By running this as nginx, we ensure
that new files are owned by the nginx user.

### Permission Issue

When running Composer commands you may come across the following error
```
[ErrorException]
file_put_contents(/var/www/drupal/web/sites/default/settings.php): failed to open stream: Operation not permitted
```
This means that Composer is not able to write to your settings.php file. If you run into this
error, giving write permission to the nginx user should fix it.

## Drupal Database Updates

After getting the newest code, you'll want to use Drush to update the Drupal database
and run any other update hooks that have been introduced. However, _YOU SHOULD BACK UP
Expand Down

0 comments on commit b3d949a

Please sign in to comment.