Skip to content

Commit

Permalink
Merge pull request Islandora-Devops#132 from jhu-idc/issue-131
Browse files Browse the repository at this point in the history
 import config/sync when starting with no pre-existing state
  • Loading branch information
birkland authored May 24, 2021
2 parents 2381e15 + 6342c32 commit 5212100
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
32 changes: 17 additions & 15 deletions IDC.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,43 @@ start from a known snapshot state, which currently is an entirely empty (but ini

To reset to a known Drupal state, run

docker-compose down -v
docker-compose up -d
make reset

This will remove all content from volumes that you may have added, launch using the snapshot as its initial state.
This will remove all content from volumes that you may have added, remove all php files downloaded by composer,
launch using the snapshot as its initial state, then import any config from config/sync.
`composer install` will run automatically as part of the startup process.

To dump the site's configuration so that it can be committed to `git`, do
A slightly quicker way to reset to a known state is:

make config-export
docker-compose down -v
make up

To take a snapshot of Drupal's current content, do
This removes all content from volumes, restores from the last snapshot, pulls in config from config/sync, but does _not_ remove composer-managed PHP files. `composer install` will still run upon startup, but it needs to do much less.

make snapshot
To dump the site's configuration so that it can be committed to `git`, do

See [snapshots](#snapshots) for more information on how to make and publish snapshots
make config-export

## Make targets

There are several Make targets in the `Makefile`, and its idc-specific companion `idc.Makefile` (which are included by default,
so no need to do anything special other than `make` to invoke them). A few useful targets are as follows:

* **make bootstrap** Burn everything down and create a fresh installation from scratch, deleting any pre-existing data, and starting from a completely empty state. Only the list of modules in `composer.json` (and dependencies in `composer.lock`) survives the process.
* **make reset** Burn everything down and create a fresh installation _from the snapshot image_. Unlike `make bootstrap`, modules and dependencies **do not** survive; they will be installed when the drupal container starts. Does not pull in configuration from config/sync, will use the active configuration present in the snapshot.
* **make composer-install** Use the Drupal container to run a `composer install`. This avoids having to install composer on your local system.
* **make reset** Burn everything down and create a fresh installation _from the snapshot image_. composer-installed modules and dependencies **do not** survive; they will be deleted, then installed from scratch via `composer install` when the drupal container starts. Once up, configuration will from `config/sync` will be imported.
* **make composer-install** Use the Drupal container to run a `composer install`. This avoids having to install composer on your local system. Note: the Drupal image startup process implicitly runs `composer install` already, so this make target is used for on-demand composer installs.
* **make cache-rebuild** Uses Drush inside the Drupal container to rebuild Drupal's cache.
* **make config-export** Exports all current active Drupal config to the `codebase/config/sync` directory, so that it can be committed to git.
* **make snapshot** Create a snapshot of the current Drupal state (db, content files, etc), so that you can reset to this state at will, or push it so that others can.
* **make snapshot-push** Push the current snapshot image to the container registry
* **make up** Brings up the development environment, including running `composer install`.
* **make test** Runs all tests.
* **make up** Brings up the development environment, including running `composer install`. If there is no pre-existing state (e.g. after a `docker compose down -v`), this will load initial state from the current snapshot, and pull in config from `config/sync`. Otherwise, if there _is_ pre-existing state (i.e. after a `docker stop`), docker will start, `composer install` will run, but configuration from `config/sync` will _not_ be imported.
* **make test** Runs all tests. Optionally, takes a `test=` parameter for running a particular test suite. NOTE: Running all tests without a `test=` argument will result in all local state being wiped out
* **make dev-up** Launches the stack with a Drupal image configured with XDebug for IDE-based debugging. Updates the environment requiring `make dev-down` to be invoked at the conclusion of a development session.
* **make dev-down** Stops the Drupal development image, and resets the environment to using production.

A few specialized targets are:

* **make bootstrap** Burn everything down and create a fresh installation from scratch, deleting any pre-existing data, and starting from a completely empty state. Only the list of modules in `composer.json` (and dependencies in `composer.lock`) survives the process.
* **make minio-bucket** Create a new bucket in minio based on the environment variables present in `.env`
* **make snapshot** Create a snapshot of the current Drupal state (db, content files, etc), so that you can reset to this state at will, or push it so that others can.
* **make snapshot-push** Push the current snapshot image to the container registry
* **make static-docker-compose.yml** Make a docker-compose.yml based off non-development "static" environment. Notably:
* A `drupal-static` image is built or pulled, which has `codebase` baked in, and is used in place of the normal `drupal` image
* `codebase` is no longer bind mounted
Expand Down
10 changes: 9 additions & 1 deletion idc.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,22 @@ start:
if [ "$$?" -eq "0" -a -n "$${DRUPAL_STATE_EXISTS}" ]; then break; fi; \
done; \
if [ "$${DRUPAL_STATE_EXISTS}" != "1" ] ; then \
echo "No Drupal state found"; \
echo "No Drupal state found. Loading from snapshot, and importing config from config/sync"; \
${MAKE} db_restore; \
${MAKE} _docker-up-and-wait; \
${MAKE} config-import; \
else echo "Pre-existing Drupal state found, not loading db from snapshot"; \
${MAKE} _docker-up-and-wait; \
fi;

.PHONY: _docker-up-and-wait
.SILENT: _docker-up-and-wait
_docker-up-and-wait:
docker-compose up -d
sleep 5
docker-compose exec -T drupal /bin/sh -c "while true ; do echo \"Waiting for Drupal to start ...\" ; if [ -d \"/var/run/s6/services/nginx\" ] ; then s6-svwait -u /var/run/s6/services/nginx && exit 0 ; else sleep 5 ; fi done"


# Static drupal image, with codebase baked in. This image
# is tagged based on the current git hash/tag. If the image is not present
# locally, nor pullable, then this is built locally. Ultimately, this image is
Expand Down

0 comments on commit 5212100

Please sign in to comment.