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

Experiments in Assets, and bootstrapping Drupal #4

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ ActiveMQ_LOG=WARN
### Drupal
# TO DO: Determine if ENVs are needed here to allow for tuning, flexibility in configuration or exposing features
# TO DO: Determine what are appropriate logging levels and pipe to stdout, add logging levels below

# TO DO: Use secrets for password
DRUPAL_MYSQL_DATABASE=isle
DRUPAL_MYSQL_USER=isle
DRUPAL_MYSQL_PASSWORD=moo

### Blazegraph
# TO DO: Determine what ENVs are necessary for configuration or startup.
Expand Down Expand Up @@ -51,12 +54,8 @@ CANTALOUPE_GID=999
# TO DO: Determine if ENVs are needed here to allow for tuning, flexibility in configuration or exposing features
# TO DO: Determine what are appropriate logging levels and pipe to stdout, add logging levels below
# TO DO: How to expose slow query log abilities?

MYSQL_ROOT_PASSWORD=# Replace this comment with a recommended password of 26 alpha-numeric characters. Should this be here?
MYSQL_DATABASE=drupal
MYSQL_USER=user
MYSQL_PASSWORD=password
MYSQL_ROOT_PASSWORD=password
# TO DO: Use secrets for passwords
MYSQL_ROOT_PASSWORD=moo


### Postgres
Expand Down Expand Up @@ -123,11 +122,10 @@ TRAEFIK_API_INSECURE=false
# TO DO: Determine what ENVs are necessary for configuration or startup.
# TO DO: Determine what are appropriate logging levels and pipe to stdout, add logging levels below. Should this be here?
MATOMO_DATABASE_HOST=mysql
MYSQL_PASSWORD=password
MYSQL_DATABASE=matomo
MYSQL_USER=matomo
MATOMO_DATABASE_ADAPTER=mysql
MATOMO_DATABASE_TABLES_PREFIX=matomo_
MATOMO_DATABASE_USERNAME=matomo
MATOMO_DATABASE_PASSWORD=password
MATOMO_DATABASE_DBNAME=matomo

ASSETS_BOOTSTRAP=true
15 changes: 15 additions & 0 deletions build/assets/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:latest
COPY data/assets.tar.gz /
COPY create_dirs.sh /
RUN tar xzvf /assets.tar.gz -C / && \
sh /create_dirs.sh

FROM alpine:latest

RUN apk --no-cache add docker-cli
COPY --from=0 /assets/ /assets
COPY *.sh /bin/

RUN chmod 700 /bin/*.sh

ENTRYPOINT [ "/bin/entrypoint.sh" ]
31 changes: 31 additions & 0 deletions build/assets/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

MYSQL_HOST=isle-dc-mysql-$CONTAINER_SHORT_ID
DRUPAL_HOST=isle-dc-drupal-$CONTAINER_SHORT_ID

# First, create the Drupal user
echo "Creating Drupal db and user in mysql"
docker exec -i $MYSQL_HOST bash <<EOF
mysql -uroot -p${MYSQL_ROOT_PASSWORD} <<SQL_EOF
CREATE USER IF NOT EXISTS '${DRUPAL_MYSQL_USER}'@'%' IDENTIFIED BY '${DRUPAL_MYSQL_PASSWORD}';
GRANT ALL PRIVILEGES ON *.* TO '${DRUPAL_MYSQL_USER}'@'%';
FLUSH PRIVILEGES;
SQL_EOF
EOF

# Install Drupal site
echo "Installing basic Drupal site"
docker exec -i $DRUPAL_HOST bash <<EOF
drush site-install standard -y --root=/var/www/html/drupal/web --site-name="Islandora 8" --account-name=admin --account-pass=islandora --db-url=mysql://${DRUPAL_MYSQL_USER}:${DRUPAL_MYSQL_PASSWORD}@${MYSQL_HOST}/${DRUPAL_MYSQL_DATABASE} --debug -vvv
EOF

# Configure the Drupal site. I think this is where the bulk of
# The Islandora install action would occur
echo "Configuring Drupal site"
docker exec -i $DRUPAL_HOST bash <<EOF
composer require drupal/bootstrap
drush theme:enable bootstrap
drush config:set system.theme default bootstrap
composer require drupal/search_api_solr
drush en -y search_api_solr
EOF
15 changes: 15 additions & 0 deletions build/assets/create_dirs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
if [ ! -d /assets/solr ]; then
mkdir /assets/solr
chown 8983:8983 /assets/solr
fi

if [ ! -d /assets/drupal ]; then
mkdir /assets/drupal
chown 33:33 /assets/drupal
fi

if [ ! -d /assets/mysql ]; then
mkdir /assets/mysql
chown 999:999 /assets/mysql
fi
Binary file added build/assets/data/assets.tar.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions build/assets/dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

tar czvf /dump/assets.tar.gz /assets
7 changes: 7 additions & 0 deletions build/assets/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

#if [ -z $ASSETS_BOOTSTRAP ]; then
# exit 0
#fi

tail -f /dev/null
19 changes: 19 additions & 0 deletions build/drupal/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM drupal:8.8.2-apache

ENV DRUSH_VERSION=9.7.2 \
COMPOSER_MEMORY_LIMIT=-1

RUN apt-get update && apt-get install -y mysql-client && \
curl -sS https://getcomposer.org/installer | php && \
ln -s /var/www/html/composer.phar /usr/local/bin/composer && \
composer require drush/drush:${DRUSH_VERSION} && \
curl -L https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar > /usr/local/bin/drush && \
chmod +x /usr/local/bin/drush && \
rm -rf /var/www/html/modules && \
rm -rf /var/www/html/profiles && \
rm -rf /var/www/html/sites && \
rm -rf /var/www/html/themes && \
ln -s /mnt/assets/modules /var/www/html/modules && \
ln -s /mnt/assets/profiles /var/www/html/profiles && \
ln -s /mnt/assets/sites /var/www/html/sites && \
ln -s /mnt/assets/themes /var/www/html/themes
32 changes: 22 additions & 10 deletions docker-compose.mvp1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ services:

drupal:
# review https://github.com/docker-library/docs/blob/master/drupal/content.md
image: drupal:8.8.1-apache
image: birkland/isle-drupal:8.8.2
build: ./build/drupal
container_name: isle-dc-drupal-${CONTAINER_SHORT_ID}
env_file:
- .env
Expand All @@ -45,18 +46,11 @@ services:
depends_on:
- mysql
- traefik
- assets
ports:
- 8080:80
volumes:
# TO DO: Determine what is Drupal volume setup?
# Disagreement re volumes in Drupal community https://github.com/docker-library/drupal/issues/3
# Is it an idea to only mount sites data and rebuild image with Drupal code changes ?
# Volumes setup should be reviewed https://hub.docker.com/_/drupal/
# TO DO: Determine what should be in config/drupal? .keep file is in place for now to allow empty dir to appear.
- ./data/drupal/modules:/var/www/html/modules
- ./data/drupal/profiles:/var/www/html/profiles
- ./data/drupal/sites:/var/www/html/sites
- ./data/drupal/themes:/var/www/html/themes
- isle-dc-drupal-data:/mnt/assets
# TO DO: Determine what type of container handling is needed
restart: always
labels:
Expand Down Expand Up @@ -93,6 +87,7 @@ services:
- isle-dc-internal
depends_on:
- traefik
- assets
ports:
- "3306:3306"
volumes:
Expand All @@ -115,12 +110,28 @@ services:
- isle-dc-internal
depends_on:
- traefik
- assets
ports:
- "8082:8080"
volumes:
- isle-dc-solr-data:/usr/local/solr
# TO DO: Determine what type of container handling is needed
restart: always

assets:
image: birkland/isle-assets:0.1.0
build: ./build/assets
container_name: isle-dc-assets-${CONTAINER_SHORT_ID}
env_file:
- .env
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./build/assets/data:/dump
- isle-dc-mysql-data:/assets/mysql
- isle-dc-solr-data:/assets/solr
- isle-dc-drupal-data:/assets/drupal
networks:
- isle-dc-internal


networks:
Expand All @@ -129,6 +140,7 @@ networks:


volumes:
isle-dc-drupal-data:
isle-dc-mysql-data:
# isle-dc-postgres-data # Added to prototype but not currently used
isle-dc-solr-data: