Switch to using Docker
This commit refactors all code in this project to make use of docker. This has not yet been documented properly.
This commit is contained in:
parent
9ece280e72
commit
76ef5d8e68
43 changed files with 943 additions and 545 deletions
6
distillery/resources/compose/runtime/.dockerignore
Normal file
6
distillery/resources/compose/runtime/.dockerignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Ignore everything
|
||||
*
|
||||
|
||||
# allow the following files:
|
||||
!conf/*
|
||||
!scripts/*
|
||||
27
distillery/resources/compose/runtime/.env.sample
Normal file
27
distillery/resources/compose/runtime/.env.sample
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#######################
|
||||
# Meta Settings
|
||||
#######################
|
||||
|
||||
# Real path for volumes to be stored
|
||||
REAL_PATH=/var/www/example.slug
|
||||
|
||||
#######################
|
||||
### Web Server settings
|
||||
#######################
|
||||
# the hostname for the website
|
||||
VIRTUAL_HOST=example.com
|
||||
|
||||
# optional letsencrypt support
|
||||
# when blank, ignore
|
||||
LETSENCRYPT_HOST=
|
||||
LETSENCRYPT_EMAIL=
|
||||
|
||||
### SQL settings
|
||||
MYSQL_HOST=mysql
|
||||
MYSQL_USER=user
|
||||
MYSQL_PASS=pass
|
||||
|
||||
### GraphDB settings
|
||||
GRAPHDB_HOST=graphdb
|
||||
GRAPHDB_USER=user
|
||||
GRAPHDB_PASS=pass
|
||||
75
distillery/resources/compose/runtime/Dockerfile
Normal file
75
distillery/resources/compose/runtime/Dockerfile
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
FROM php:7-apache-buster
|
||||
WORKDIR /var/www
|
||||
|
||||
# install and enable the various required php extension
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libcurl4-openssl-dev curl \
|
||||
libpng-dev \
|
||||
libicu-dev \
|
||||
libxml2-dev \
|
||||
libssh2-1-dev \
|
||||
sudo \
|
||||
zip unzip \
|
||||
default-mysql-client \
|
||||
&& \
|
||||
docker-php-source extract && \
|
||||
docker-php-ext-install \
|
||||
curl \
|
||||
gd \
|
||||
intl \
|
||||
soap \
|
||||
mysqli \
|
||||
opcache \
|
||||
pdo_mysql \
|
||||
xml \
|
||||
xmlrpc \
|
||||
&& \
|
||||
pecl install ssh2-1.2 && \
|
||||
docker-php-ext-enable \
|
||||
curl \
|
||||
gd \
|
||||
intl \
|
||||
mysqli \
|
||||
opcache \
|
||||
pdo_mysql \
|
||||
soap \
|
||||
ssh2 \
|
||||
mysqli \
|
||||
xml \
|
||||
xmlrpc \
|
||||
&& \
|
||||
docker-php-source delete
|
||||
|
||||
# enable the apache rewrite mod
|
||||
RUN a2enmod rewrite
|
||||
|
||||
# install composer and add it to path
|
||||
RUN curl -sS https://getcomposer.org/installer | php && \
|
||||
mv composer.phar /usr/local/bin/composer
|
||||
ENV PATH "/usr/local/bin:/var/www/data/project/vendor/bin:$PATH"
|
||||
|
||||
# remove default configuration
|
||||
RUN rm /etc/apache2/sites-available/*.conf && \
|
||||
rm /etc/apache2/sites-enabled/*.conf
|
||||
# Add wisski configuration
|
||||
ADD conf/ports.conf /etc/apache2/ports.conf
|
||||
ADD conf/wisski.conf /etc/apache2/sites-available/wisski.conf
|
||||
RUN a2ensite wisski
|
||||
|
||||
# volumes for composer
|
||||
VOLUME /var/www/.composer
|
||||
VOLUME /var/www/data
|
||||
|
||||
# increase the php memory limit to 2g
|
||||
RUN echo 'memory_limit=2G' > /usr/local/etc/php/conf.d/memory-limit.ini
|
||||
|
||||
# Add and configure the entrypoint
|
||||
ADD scripts/entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
CMD ["apache2-foreground"]
|
||||
|
||||
# Add the provision script
|
||||
ADD scripts/provision_container.sh /provision_container.sh
|
||||
|
||||
# expose port 8080
|
||||
EXPOSE 8080
|
||||
4
distillery/resources/compose/runtime/conf/ports.conf
Normal file
4
distillery/resources/compose/runtime/conf/ports.conf
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# This file configures where apache should listen.
|
||||
# Because we are running as a limited user, we want to listen on a high port.
|
||||
# For this we use port 8080
|
||||
Listen 8080
|
||||
22
distillery/resources/compose/runtime/conf/wisski.conf
Normal file
22
distillery/resources/compose/runtime/conf/wisski.conf
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<VirtualHost *:8080>
|
||||
# the document root -- /var/www/data/project/web
|
||||
DocumentRoot /var/www/data/project/web
|
||||
|
||||
<Directory /var/www/data/project/web>
|
||||
# add types for .owl and .rdf
|
||||
AddType application/rdf+xml .owl
|
||||
AddType application/rdf+xml .rdf
|
||||
|
||||
# Rewrite the 'ontology' directory
|
||||
ReWriteRule ^(ontology/[^/]+/).+ $1 [R=303,L]
|
||||
ReWriteRule ^(ontology/[^/]+)/$ sites/default/files/$1.owl [L]
|
||||
|
||||
# Allow overrides of symlinks
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
ErrorLog /dev/stderr
|
||||
CustomLog /dev/stdout combined
|
||||
</VirtualHost>
|
||||
24
distillery/resources/compose/runtime/docker-compose.yml
Normal file
24
distillery/resources/compose/runtime/docker-compose.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
version: "3.7"
|
||||
|
||||
services:
|
||||
runtime:
|
||||
build: .
|
||||
restart: always
|
||||
environment:
|
||||
# port and hostname for this image to use
|
||||
VIRTUAL_HOST: ${VIRTUAL_HOST}
|
||||
VIRTUAL_PORT: 8080
|
||||
|
||||
# optional letsencrypt email
|
||||
LETSENCRYPT_HOST: ${LETSENCRYPT_HOST}
|
||||
LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
|
||||
|
||||
# the volumes to
|
||||
volumes:
|
||||
- ${REAL_PATH}/.composer:/var/www/.composer
|
||||
- ${REAL_PATH}/data:/var/www/data
|
||||
|
||||
networks:
|
||||
default:
|
||||
external:
|
||||
name: distillery
|
||||
11
distillery/resources/compose/runtime/scripts/entrypoint.sh
Executable file
11
distillery/resources/compose/runtime/scripts/entrypoint.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script contains
|
||||
|
||||
# chown the volumes to make sure they can be read and written by the limited user
|
||||
chown www-data:www-data /var/www
|
||||
chown www-data:www-data /var/www/.composer
|
||||
chown www-data:www-data /var/www/data/
|
||||
|
||||
# run the original entrypoint
|
||||
docker-php-entrypoint "$@"
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
function log_info() {
|
||||
echo -e "\033[1m$1\033[0m"
|
||||
}
|
||||
|
||||
function log_ok() {
|
||||
echo -e "\033[0;32m$1\033[0m"
|
||||
}
|
||||
|
||||
log_info " => Reading configuration variables"
|
||||
|
||||
INSTANCE_DOMAIN="$1"
|
||||
echo "INSTANCE_DOMAIN=$INSTANCE_DOMAIN"
|
||||
shift 1
|
||||
|
||||
MYSQL_DATABASE="$1"
|
||||
echo "MYSQL_DATABASE=$MYSQL_DATABASE"
|
||||
MYSQL_USER="$2"
|
||||
echo "MYSQL_USER=$MYSQL_USER"
|
||||
MYSQL_PASSWORD="$3"
|
||||
echo "MYSQL_PASSWORD=$MYSQL_PASSWORD"
|
||||
|
||||
shift 3
|
||||
|
||||
GRAPHDB_REPO="$1"
|
||||
echo "GRAPHDB_REPO=$GRAPHDB_REPO"
|
||||
GRAPHDB_USER="$2"
|
||||
echo "GRAPHDB_USER=$GRAPHDB_USER"
|
||||
GRAPHDB_PASSWORD="$3"
|
||||
echo "GRAPHDB_PASSWORD=$GRAPHDB_PASSWORD"
|
||||
shift 3
|
||||
|
||||
DRUPAL_USER="$1"
|
||||
echo "DRUPAL_USER=$DRUPAL_USER"
|
||||
DRUPAL_PASS="$2"
|
||||
echo "DRUPAL_PASS=$DRUPAL_PASS"
|
||||
shift 2
|
||||
|
||||
USE_DRUPAL_9="$1"
|
||||
echo "USE_DRUPAL_9=$USE_DRUPAL_9"
|
||||
shift 1
|
||||
|
||||
log_info " => Preparing installation environment"
|
||||
BASE_DIR="/var/www/data"
|
||||
COMPOSER_DIR="$BASE_DIR/project"
|
||||
WEB_DIR="$COMPOSER_DIR/web"
|
||||
ONTOLOGY_DIR="$WEB_DIR/sites/default/files/ontology"
|
||||
|
||||
log_info " => Creating '$COMPOSER_DIR'"
|
||||
mkdir -p "$COMPOSER_DIR"
|
||||
cd "$COMPOSER_DIR"
|
||||
|
||||
function drupal_sites_permission_workaround() {
|
||||
chmod -R u+w "$WEB_DIR/sites/" || true
|
||||
}
|
||||
|
||||
# Create a new composer project.
|
||||
log_info " => Creating composer project"
|
||||
if [ -z "${USE_DRUPAL_9}" ]; then
|
||||
composer create-project 'drupal/recommended-project:^8.9.0' .
|
||||
else
|
||||
composer create-project 'drupal/recommended-project:^9.0.0' .
|
||||
fi
|
||||
|
||||
# Install drush so that we can automate a lot of things
|
||||
log_info " => Installing 'drush'"
|
||||
composer require drush/drush
|
||||
|
||||
# Use 'drush' to run the site-installation.
|
||||
# Here we need to use the username, password and database creds we made above.
|
||||
log_info " => Running drupal installation scripts"
|
||||
drush site-install standard --yes --site-name=${INSTANCE_DOMAIN} \
|
||||
--account-name=$DRUPAL_USER --account-pass=$DRUPAL_PASS \
|
||||
--db-url=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@sql/${MYSQL_DATABASE}
|
||||
drupal_sites_permission_workaround
|
||||
|
||||
# create a directory for ontologies.
|
||||
log_info " => Creating '$ONTOLOGY_DIR'"
|
||||
mkdir -p "$ONTOLOGY_DIR"
|
||||
|
||||
# Install the Wisski packages.
|
||||
log_info " => Installing Wisski packages"
|
||||
cd "$COMPOSER_DIR"
|
||||
|
||||
# install the development version when requested
|
||||
if [ -z "${USE_DRUPAL_9}" ]; then
|
||||
composer require 'drupal/wisski'
|
||||
else
|
||||
composer require 'drupal/wisski:2.x-dev'
|
||||
fi
|
||||
|
||||
drupal_sites_permission_workaround
|
||||
composer require drupal/inline_entity_form
|
||||
|
||||
drupal_sites_permission_workaround
|
||||
composer require drupal/imagemagick
|
||||
|
||||
drupal_sites_permission_workaround
|
||||
composer require drupal/image_effects
|
||||
|
||||
drupal_sites_permission_workaround
|
||||
composer require drupal/colorbox
|
||||
|
||||
log_info " => Enable Wisski modules"
|
||||
drush pm-enable --yes wisski_core wisski_linkblock wisski_pathbuilder wisski_adapter_sparql11_pb wisski_salz
|
||||
drupal_sites_permission_workaround
|
||||
|
||||
log_info " => Provisioning is now complete. "
|
||||
log_ok "Your installation details are as follows:"
|
||||
function printdetails() {
|
||||
echo "URL: http://$INSTANCE_DOMAIN"
|
||||
echo "Username: $DRUPAL_USER"
|
||||
echo "Password: $DRUPAL_PASS"
|
||||
log_info " => Your GraphDB details (for WissKI Salz) are: "
|
||||
echo "Read URL: http://triplestore:7200/repositories/$GRAPHDB_REPO"
|
||||
echo "Write URL: http://triplestore:7200/repositories/$GRAPHDB_REPO/statements"
|
||||
echo "Username: $GRAPHDB_USER"
|
||||
echo "Password: $GRAPHDB_PASSWORD"
|
||||
echo "Writable: yes"
|
||||
echo "Default Graph URI: http://$INSTANCE_DOMAIN/#"
|
||||
echo "Ontology Paths: (empty)"
|
||||
echo "SameAs property: http://www.w3.org/2002/07/owl#sameAs"
|
||||
}
|
||||
printdetails
|
||||
Loading…
Add table
Add a link
Reference in a new issue