Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starter site integration #287

Merged
merged 10 commits into from
Oct 11, 2022
50 changes: 48 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ run-islandora-migrations:
#docker-compose exec -T drupal with-contenv bash -lc "for_all_sites import_islandora_migrations"
# this line can be reverted when https://github.com/Islandora-Devops/isle-buildkit/blob/fae704f065435438828c568def2a0cc926cc4b6b/drupal/rootfs/etc/islandora/utilities.sh#L557
# has been updated to match
docker-compose exec -T drupal with-contenv bash -lc 'drush -l $(SITE) migrate:import islandora_defaults_tags,islandora_tags'
docker-compose exec -T drupal with-contenv bash -lc 'drush -l $(SITE) migrate:import $(MIGRATE_IMPORT_USER_OPTION) islandora_defaults_tags,islandora_tags'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the MIGRATE_IMPORT_USER_OPTION variable is not otherwise specified, $(MIGRATE_IMPORT_USER_OPTION) should just give the empty string, which should continue to run this as it was... but can now specify the variable (as something like MIGRATE_IMPORT_USER_OPTION=--userid=1 (as is being done under the starter-finalize make target)) in order to have it perform the migrate:import command as a particular user, of whom we can assure the fedoraAdmin role is present.


.PHONY: solr-cores
## Creates solr-cores according to the environment variables.
Expand Down Expand Up @@ -518,4 +518,50 @@ fix_masonry:
## This fixes a know issues with views when using the make local build. The error must be triggered before this will work.
fix_views:
docker cp scripts/patch_views.sh $$(docker ps --format "{{.Names}}" | grep drupal):/var/www/drupal/patch_views.sh
docker-compose exec -T drupal with-contenv bash -lc "bash /var/www/drupal/patch_views.sh ; rm /var/www/drupal/patch_views.sh ; drush cr"
docker-compose exec -T drupal with-contenv bash -lc "bash /var/www/drupal/patch_views.sh ; rm /var/www/drupal/patch_views.sh ; drush cr"

.PHONY: starter
## Make a local site with codebase directory bind mounted, using starter site.
starter: QUOTED_CURDIR = "$(CURDIR)"
starter: generate-secrets
$(MAKE) starter-init ENVIRONMENT=starter
if [ -z "$$(ls -A $(QUOTED_CURDIR)/codebase)" ]; then \
docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'composer create-project islandora/islandora-starter-site:dev-main /tmp/codebase; mv /tmp/codebase/* /home/root;'; \
fi
$(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIROMENT=starter
docker-compose up -d --remove-orphans
docker-compose exec -T drupal with-contenv bash -lc 'chown -R nginx:nginx .'
$(MAKE) starter-finalize ENVIROMENT=starter

.PHONY: starter_dev
## Make a local site with codebase directory bind mounted, using cloned starter site.
starter_dev: QUOTED_CURDIR = "$(CURDIR)"
starter_dev: generate-secrets
$(MAKE) starter-init ENVIRONMENT=starter_dev
if [ -z "$$(ls -A $(QUOTED_CURDIR)/codebase)" ]; then \
docker container run --rm -v $(CURDIR)/codebase:/home/root $(REPOSITORY)/nginx:$(TAG) with-contenv bash -lc 'git clone -b main https://github.com/Islandora/islandora-starter-site /home/root;'; \
fi
$(MAKE) set-files-owner SRC=$(CURDIR)/codebase ENVIROMENT=starter_dev
docker-compose up -d --remove-orphans
docker-compose exec -T drupal with-contenv bash -lc 'composer install'
docker-compose exec -T drupal with-contenv bash -lc 'chown -R nginx:nginx .'
$(MAKE) starter-finalize ENVIROMENT=starter_dev


.PHONY: starter-init
starter-init: generate-secrets
$(MAKE) download-default-certs
$(MAKE) -B docker-compose.yml
$(MAKE) pull
mkdir -p $(CURDIR)/codebase

.PHONY: starter-finalize
starter-finalize:
$(MAKE) drupal-database update-settings-php
docker-compose exec -T drupal with-contenv bash -lc "drush si -y --existing-config minimal --account-pass $(shell cat secrets/live/DRUPAL_DEFAULT_ACCOUNT_PASSWORD)"
docker-compose exec -T drupal with-contenv bash -lc "drush -l $(SITE) user:role:add fedoraadmin admin"
MIGRATE_IMPORT_USER_OPTION=--userid=1 $(MAKE) hydrate
docker-compose exec -T drupal with-contenv bash -lc 'drush -l $(SITE) migrate:import --userid=1 islandora_fits_tags'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for reference, this islandora_fits_tags migration is being introduced in roblib/islandora_fits#14 , and has been included in islandora/islandora-starter-site as a patch: https://github.com/Islandora/islandora-starter-site/blob/b954409a0fb47dbbef0a415f25cf66821ce023bb/composer.json#L97-L101

#docker-compose exec -T drupal with-contenv bash -lc 'chown -R `id -u`:nginx /var/www/drupal'
#docker-compose exec -T drupal with-contenv bash -lc 'drush migrate:rollback islandora_defaults_tags,islandora_tags'
Comment on lines +565 to +566
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copypasta from the local target. Could be dropped if we want?

$(MAKE) login
36 changes: 36 additions & 0 deletions build/docker-compose/docker-compose.starter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Container does not perform any initialization aside from importing env-vars from `confd`.
# Users are expected to manually set up their site using a combination of the following:
# - Makefile targets
# - composer requires / install
# - Drush commands
# - Manual changes to the codebase directory
version: "3.7"
networks:
default:
internal: true
gateway:
external: true
volumes:
drupal-sites-data:
solr-data:
services:
drupal:
restart: ${RESTART_POLICY:-unless-stopped}
image: ${REPOSITORY:-islandora}/drupal:${TAG:-latest}
volumes:
- ../../codebase:/var/www/drupal:delegated
- drupal-sites-data:/var/www/drupal/web/sites/default/files
- solr-data:/opt/solr/server/solr
environment:
DRUPAL_DEFAULT_INSTALL_EXISTING_CONFIG: ${INSTALL_EXISTING_CONFIG}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and starter_dev's) are just copypasta from the docker-compose.local.yml... wherein it seems this value isn't actually used? As in: grep'ing here in isle-dc, just finding it being specified, and grep'ing in the isle-buildkit, it seems to pass the variable in the environment; however, it does not appear to be used in any kind of site:install wrapper... indeed, the site:install(/si) is in our Makefile (where we would have to pass the --existing-config option)... so it's... kind of implied that this shouldn't do anything?

DRUPAL_DEFAULT_PROFILE: ${DRUPAL_INSTALL_PROFILE}
depends_on:
# Requires a the very minimum a database.
- ${DRUPAL_DATABASE_SERVICE}
# Extends docker-compose.solr.yml
solr:
volumes:
# On a production site you may not want to take this approach but instead refer to each of the cores
# data directories specifically and maintain the configuration as part of a customized image, where
# in your configuration is Solr managed under source control somewhere.
- solr-data:/opt/solr/server/solr
36 changes: 36 additions & 0 deletions build/docker-compose/docker-compose.starter_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Container does not perform any initialization aside from importing env-vars from `confd`.
# Users are expected to manually set up their site using a combination of the following:
# - Makefile targets
# - composer requires / install
# - Drush commands
# - Manual changes to the codebase directory
version: "3.7"
networks:
default:
internal: true
gateway:
external: true
volumes:
drupal-sites-data:
solr-data:
services:
drupal:
restart: ${RESTART_POLICY:-unless-stopped}
image: ${REPOSITORY:-islandora}/drupal:${TAG:-latest}
volumes:
- ../../codebase:/var/www/drupal:delegated
- drupal-sites-data:/var/www/drupal/web/sites/default/files
- solr-data:/opt/solr/server/solr
environment:
DRUPAL_DEFAULT_INSTALL_EXISTING_CONFIG: ${INSTALL_EXISTING_CONFIG}
DRUPAL_DEFAULT_PROFILE: ${DRUPAL_INSTALL_PROFILE}
depends_on:
# Requires a the very minimum a database.
- ${DRUPAL_DATABASE_SERVICE}
# Extends docker-compose.solr.yml
solr:
volumes:
# On a production site you may not want to take this approach but instead refer to each of the cores
# data directories specifically and maintain the configuration as part of a customized image, where
# in your configuration is Solr managed under source control somewhere.
- solr-data:/opt/solr/server/solr
1 change: 1 addition & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ CODE_SERVER_PORT=8443
###############################################################################

DOMAIN=islandora.traefik.me
SITE=https://${DOMAIN}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is provided to many(/most?) drush commands, it makes sense to have it default to something that should be valid for looking up the JWT key instead of the default.

DISABLE_SYN=false
FEDORA_6=true
RESTART_POLICY=unless-stopped
Expand Down