Skip to content

Commit 25f3d97

Browse files
committed
BKDK-521 Adjusted os2subsites docker config
1 parent 13335b5 commit 25f3d97

File tree

12 files changed

+969
-3
lines changed

12 files changed

+969
-3
lines changed

.docker/os2web-subsites/.env.example

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,73 @@
22
# Copy and rename this file to .env at root of this project.
33
#
44

5+
# Uncomment and populate as needed.
6+
## Subsite admin UI db creadentials
7+
MYSQL_DATABASE=os2subsites
8+
MYSQL_HOSTNAME=mariadb
9+
MYSQL_ROOT_PASSWORD=root
10+
MYSQL_PASSWORD=os2subsites
11+
MYSQL_PORT=3306
12+
MYSQL_USER=os2subsites
13+
14+
## Drupal salt
15+
DRUPAL_HASH_SALT=w-NR7Q2C3URQH6qdRvDPlbxVqdvyGMbsOwyXgtqkdJGNI7FBMbrD79UMx2DDNlSqvfmY-OOKLw
16+
## Domain suffix that would be used for subsites
17+
DOMAIN_SUFFIX=os2subsites.local
18+
## Path to base site config directory
19+
BASE_SUBSITE_CONFIG_DIR=/opr/drupal/config/base.${DOMAIN_SUFFIX}
20+
21+
# OS2SUBSITE common varaibles.
22+
## Flag for using environment variables
23+
## Comment this variale to use values from `config.sh file`
24+
USE_ENV_CONFIG=1
25+
## Drupal project root directory
26+
BASEDIR=/opt/drupal
27+
SERVERIP=127.0.0.1
28+
## Default Drupal profile for subsites.
29+
## Use `base_config` value
30+
PROFILE=base_config
31+
ALLOWED_INSTALL_PROFILES=minimal,base_config
32+
## Email used for subsite admin user.
33+
34+
## Path to
35+
SCRIPTDIR=/opt/drupal/scripts/os2subsites_provision
36+
## Path to drush
37+
DRUSH=$(which drush)
38+
## Database creadentials for creating subsite db.
39+
DBHOST=mariadb
40+
DBUSER_HOST=mariadb
41+
### Optional varialbles. Leave it empty to user root as user name.
42+
DB_ROOT_USER=root
43+
### Optional varialbles. Leave it empty to user root user without password from localhost.
44+
DB_ROOT_PASSWORD=root
45+
## External db provisioning
46+
EXTERNAL_DB_PROVISIONING=1
47+
## Subsite admin pass
48+
ADMINPASS=admin
49+
## Path to subsite vhost template
50+
VHOSTTEMPLATE=${SCRIPTDIR}/../os2subsites_provision/os2subsites-vhost-template
51+
## Drupal document root directory path
52+
MULTISITE=${BASEDIR}/web
53+
## Path to file where subsites registering.
54+
SITESFILE=${MULTISITE}/sites/sites.php
55+
## Temp directory for subsites
56+
TMPDIRBASE=${BASEDIR}/tmp
57+
## Log directory for subsites
58+
LOGDIRBASE=${BASEDIR}/logs
59+
## Session directory for subsites
60+
SESSIONDIRBASE=${BASEDIR}/sessions
61+
## Username for subsite administrator user. User will be created on subsites.
62+
SITEADMIN=subsiteadmin
63+
## Apache webserver username.
64+
APACHEUSER=www-data
65+
## Root user name. Sometimes this variable is empty.
66+
USER=root
67+
# Version of Drupal core. Accepted values 7,8
68+
DRUPAL=8
69+
# Additional option for site-install command
70+
INSTALL_OPTIONS=
71+
572
## Variable used only in docker-compose.yaml
673
COMPOSE_PROJECT_NAME=os2web-subsites-docker-compose
774
# TAG=

.docker/os2web-subsites/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ RUN set -eux; \
1313
sudo; \
1414
rm -rf /var/lib/apt/lists/*
1515

16+
# Adding subsites provisioner script.
17+
RUN set -eux; \
18+
sed -i "s/\"installer-paths\": {/\"installer-paths\": {\"scripts\/{\$name\}\": \[\"bellcom\/os2subsites_provision\"\],/g" composer.json; \
19+
export COMPOSER_HOME="$(mktemp -d)"; \
20+
echo "Loading bellcom/os2subsites_provision 05042022"; \
21+
composer require bellcom/os2subsites_provision:dev-master; \
22+
ln -s /opt/drupal/scripts/os2subsites_provision/8.x/bc_subsites /opt/drupal/web/modules/custom/; \
23+
# delete composer cache.
24+
rm -rf "$COMPOSER_HOME"
25+
1626
# Adding further site specific data to image.
1727
RUN chown -R www-data:www-data /opt/drupal/tmp /opt/drupal/logs /opt/drupal/translations; \
1828
echo "<?php" > /opt/drupal/web/sites/sites.php; \
@@ -21,6 +31,12 @@ RUN chown -R www-data:www-data /opt/drupal/tmp /opt/drupal/logs /opt/drupal/tran
2131
# Additional PHP configuration for OS2Web subsites both CLI and Apache
2232
COPY php/os2web-subsites.ini /usr/local/etc/php/conf.d/os2web-subsites.ini
2333

34+
# Add OS2Subsites vhost template
35+
COPY apache/os2subsites-vhost-template /opt/drupal/scripts/os2subsites_provision/os2subsites-vhost-template
36+
37+
# Copy drupal local settings
38+
COPY settings/*.php /opt/drupal/.docker/os2web-subsites/settings/
39+
2440
# Adding entry point where required services could be started.
2541
COPY entrypoint.sh /usr/bin/
2642

@@ -34,6 +50,9 @@ RUN echo "HOME=/opt/drupal" >> /opt/drupal/.env
3450
# Addjusting php runtime.
3551
RUN ln -s /usr/local/bin/php /usr/bin/php;
3652

53+
# Allow www-data call scripts.
54+
COPY os2subsite /etc/sudoers.d/os2subsite
55+
3756
ENTRYPOINT ["entrypoint.sh"]
3857

3958
CMD ["apache2-foreground"]

.docker/os2web-subsites/apache/os2subsites-shared.conf

Whitespace-only changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# DO NOT EDIT THIS VHOST. IT WILL BE MODIFIED BY SCRIPTS. (The includes for access limits and ServerAliases)
2+
<VirtualHost *:80>
3+
<Directory [basedir]>
4+
AllowOverride All
5+
Options FollowSymLinks
6+
# Uncommenting below will only allow a limited number of Bellcom IPs access to the site
7+
#Include /etc/apache2/limit-bellcom.conf
8+
# Below blocks access without auth if the domain ends with bellcom.dk
9+
#Include /etc/apache2/limit-subsite-access.conf
10+
</Directory>
11+
12+
ServerAdmin [email protected]
13+
DocumentRoot [basedir]/public_html
14+
ServerName [domain]
15+
16+
CustomLog ${APACHE_LOG_DIR}/access.log combined
17+
ErrorLog ${APACHE_LOG_DIR}/error.log
18+
19+
php_admin_value open_basedir [basedir]:/usr/share/php
20+
php_value include_path .:[basedir]
21+
php_value error_log ${APACHE_LOG_DIR}/error.log
22+
php_value session.save_path [basedir]/sessions/[domain]
23+
php_admin_value upload_tmp_dir [basedir]/tmp/[domain]
24+
25+
php_value log_errors 1
26+
php_value html_errors 0
27+
php_value display_errors 0
28+
php_admin_value error_reporting 2047
29+
php_admin_value max_execution_time 180
30+
</VirtualHost>

.docker/os2web-subsites/docker-compose.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ services:
2626
- ./volumes/apache/sites-enabled:/etc/apache/sites-enabled
2727
- ./volumes/config:/opt/drupal/config
2828
- ./volumes/crontabs:/var/spool/cron/crontabs
29+
- ./volumes/tmp:/opt/drupal/tmp
2930
depends_on:
3031
- mariadb
3132
ports:
@@ -39,8 +40,8 @@ services:
3940
mariadb:
4041
image: mariadb:latest
4142
volumes:
42-
- /var/lib/mysql
43+
- mysql:/var/lib/mysql
4344
networks:
4445
- backend
45-
environment:
46-
MARIADB_ROOT_PASSWORD: root
46+
env_file:
47+
- .env

.docker/os2web-subsites/entrypoint.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,20 @@
33
# Starting cron service.
44
service cron start
55

6+
# Check basic file structure for subsites creator
7+
if [ ! -d "/opt/drupal/web/sites/default" ]
8+
then
9+
echo "Default sites folder doesn't exists. Create folder and standard files"
10+
mkdir -p /opt/drupal/web/sites/default/files
11+
cp -f /opt/drupal/.docker/os2web-subsites/settings/default.settings.php /opt/drupal/web/sites/default/default.settings.php
12+
cp -f /opt/drupal/.docker/os2web-subsites/settings/default.settings.php /opt/drupal/web/sites/default/settings.php
13+
echo 'include $app_root . "/" . $site_path . "/settings.local.php";' >> /opt/drupal/web/sites/default/settings.php
14+
cp -f /opt/drupal/.docker/os2web-subsites/settings/settings.local.php /opt/drupal/web/sites/default/settings.local.php
15+
chmod 755 /opt/drupal/web/sites/default /opt/drupal/web/sites/default/settings.php /opt/drupal/web/sites/default/settings.local.php
16+
chown -R www-data:www-data /opt/drupal/web/sites
17+
fi
18+
19+
# Copying shared settings file
20+
cp -f /opt/drupal/.docker/os2web-subsites/settings/shared.settings.php /opt/drupal/web/sites/shared.settings.php
21+
622
exec "$@"
11.7 KB
Binary file not shown.

.docker/os2web-subsites/os2subsite

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
www-data ALL=(root) NOPASSWD:SETENV: /opt/drupal/scripts/os2subsites_provision/subsite_add_domain.sh
2+
www-data ALL=(root) NOPASSWD:SETENV: /opt/drupal/scripts/os2subsites_provision/subsite_create.sh
3+
www-data ALL=(root) NOPASSWD:SETENV: /opt/drupal/scripts/os2subsites_provision/subsite_delete.sh
4+
www-data ALL=(root) NOPASSWD:SETENV: /opt/drupal/scripts/os2subsites_provision/subsite_remove_domain.sh
5+
www-data ALL=(root) NOPASSWD:SETENV: /opt/drupal/scripts/os2subsites_provision/phase1.sh
6+
www-data ALL=(root) NOPASSWD:SETENV: /opt/drupal/scripts/os2subsites_provision/phase2.sh
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
include $app_root . '/sites/shared.settings.php';
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* @file
4+
* Local development override configuration feature.
5+
*
6+
* To activate this feature, copy and rename it such that its path plus
7+
* filename is 'sites/default/settings.local.php'. Then, go to the bottom of
8+
* 'sites/default/settings.php' and uncomment the commented lines that mention
9+
* 'settings.local.php'.
10+
*
11+
* If you are using a site name in the path, such as 'sites/example.com', copy
12+
* this file to 'sites/example.com/settings.local.php', and uncomment the lines
13+
* at the bottom of 'sites/example.com/settings.php'.
14+
*/
15+
16+
$databases['default']['default'] = [
17+
'database' => getenv('MYSQL_DATABASE'),
18+
'driver' => 'mysql',
19+
'host' => getenv('MYSQL_HOSTNAME'),
20+
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
21+
'password' => getenv('MYSQL_PASSWORD'),
22+
'port' => getenv('MYSQL_PORT'),
23+
'prefix' => '',
24+
'username' => getenv('MYSQL_USER'),
25+
];
26+
27+
if (!empty(getenv('DRUPAL_TRUSTED_HOST'))) {
28+
$settings['trusted_host_patterns'] = ['^'.getenv('DRUPAL_TRUSTED_HOST').'$'];
29+
}
30+
31+
$settings['hash_salt'] = getenv('DRUPAL_HASH_SALT');
32+
33+
$settings['file_temp_path'] = '../tmp/default';
34+
$settings['file_private_path'] = '../private/default';
35+
$settings['config_sync_directory'] = '../config/default';
36+
37+
$config['bc_subsites.settings'] = [
38+
'enabled' => TRUE,
39+
'domain_suffix' => getenv('DOMAIN_SUFFIX'),
40+
'script_dir' => getenv('SCRIPTDIR'),
41+
'subsites_config_dir' => '../config',
42+
'base_subsite_config_dir' => getenv('BASE_SUBSITE_CONFIG_DIR'),
43+
'allowed_install_profiles' => explode(',', getenv('ALLOWED_INSTALL_PROFILES')),
44+
'default_profile' => explode(',', getenv('PROFILE')),
45+
];
46+
47+
// Passing EXTERNAL_DB_PROVISIONING into Drupal settings.
48+
if (getenv('EXTERNAL_DB_PROVISIONING')) {
49+
$settings['external_db_provisioning'] = getenv('EXTERNAL_DB_PROVISIONING');
50+
}
51+

0 commit comments

Comments
 (0)