Skip to content

Commit 914aa6d

Browse files
committed
Merge branch 'os2subsites' into develop
2 parents 64ea532 + 414a5a8 commit 914aa6d

15 files changed

+1151
-7
lines changed

.docker/os2web-subsites/.env.example

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,72 @@
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=/opt/drupal/config/base.${DOMAIN_SUFFIX}/sync
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,os2web
32+
## Email used for subsite admin user.
33+
34+
## Path to
35+
SCRIPTDIR=/opt/drupal/scripts/os2subsites_provision
36+
## Path to drush
37+
DRUSH=/usr/local/bin/drush
38+
## Database creadentials for creating subsite db.
39+
DBHOST=mariadb
40+
DBUSER_HOST=mariadb
41+
## External db provisioning. NOTE: To disable external provisioning you have to JUST comment variable
42+
EXTERNAL_DB_PROVISIONING=1
43+
PROVISIONING_SOURCES_PATH=/opt/drupal/private/subsite-credentials
44+
## For internal db provisioning you have to specify directory to mysql db files are stored. It's used for db existing check.
45+
#DBDIR=/var/lib/mysql
46+
## Subsite admin pass
47+
ADMINPASS=admin
48+
## Path to subsite vhost template
49+
VHOSTTEMPLATE=${SCRIPTDIR}/../os2subsites_provision/os2subsites-vhost-template
50+
## Drupal document root directory path
51+
MULTISITE=${BASEDIR}/web
52+
## Path to file where subsites registering.
53+
SITESFILE=${MULTISITE}/sites/sites.php
54+
## Temp directory for subsites
55+
TMPDIRBASE=${BASEDIR}/tmp
56+
## Log directory for subsites
57+
LOGDIRBASE=${BASEDIR}/logs
58+
## Session directory for subsites
59+
SESSIONDIRBASE=${BASEDIR}/sessions
60+
## Username for subsite administrator user. User will be created on subsites.
61+
SITEADMIN=subsiteadmin
62+
## Apache webserver username.
63+
APACHEUSER=www-data
64+
## Root user name. Sometimes this variable is empty.
65+
USER=root
66+
# Version of Drupal core. Accepted values 7,8
67+
DRUPAL=8
68+
# Additional option for site-install command
69+
INSTALL_OPTIONS=
70+
571
## Variable used only in docker-compose.yaml
672
COMPOSE_PROJECT_NAME=os2web-subsites-docker-compose
773
# TAG=

.docker/os2web-subsites/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.env
22
volumes/*
33
!volumes/.keep
4+
logs/*
5+
!logs/.keep

.docker/os2web-subsites/Dockerfile

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

16+
# Adding subsites provisioner script.
17+
RUN set -eux; \
18+
git clone -n https://github.com/bellcom/os2subsite_provision.git /opt/drupal/scripts/os2subsites_provision; \
19+
cd /opt/drupal/scripts/os2subsites_provision && git checkout 89a7202548462dfbb6946fda9978cfad3e77412b; \
20+
ln -s /opt/drupal/scripts/os2subsites_provision/8.x/bc_subsites /opt/drupal/web/modules/custom/
21+
1622
# Adding further site specific data to image.
1723
RUN chown -R www-data:www-data /opt/drupal/tmp /opt/drupal/logs /opt/drupal/translations; \
1824
echo "<?php" > /opt/drupal/web/sites/sites.php; \
@@ -21,6 +27,12 @@ RUN chown -R www-data:www-data /opt/drupal/tmp /opt/drupal/logs /opt/drupal/tran
2127
# Additional PHP configuration for OS2Web subsites both CLI and Apache
2228
COPY php/os2web-subsites.ini /usr/local/etc/php/conf.d/os2web-subsites.ini
2329

30+
# Add OS2Subsites vhost template
31+
COPY apache/os2subsites-vhost-template /opt/drupal/scripts/os2subsites_provision/os2subsites-vhost-template
32+
33+
# Copy drupal local settings
34+
COPY settings/*.php /opt/drupal/.docker/os2web-subsites/settings/
35+
2436
# Adding entry point where required services could be started.
2537
COPY entrypoint.sh /usr/bin/
2638

@@ -34,6 +46,9 @@ RUN echo "HOME=/opt/drupal" >> /opt/drupal/.env
3446
# Addjusting php runtime.
3547
RUN ln -s /usr/local/bin/php /usr/bin/php;
3648

49+
# Allow www-data call scripts.
50+
COPY os2subsite /etc/sudoers.d/os2subsite
51+
3752
ENTRYPOINT ["entrypoint.sh"]
3853

3954
CMD ["apache2-foreground"]

.docker/os2web-subsites/README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,121 @@ Example:
2323
```
2424

2525
`--push` - when you this option build will be pushed to docker hub.
26+
27+
## Local developemnt through docker
28+
29+
While main OS2Web solution is using Docksal for local development. It's easier for testing purposes to use bare docker-compose environment for OS2Web sibsutes.
30+
31+
It expects that all action would be performed on Docker subsites folder .docker/os2web-subsites
32+
33+
34+
### Restart docker stack
35+
36+
docker-compose down
37+
sudo rm -rf volumes/*
38+
docker volume rm os2web-subsites-docker-compose_mysql
39+
docker-compose up -d
40+
docker-compose exec php bash
41+
42+
43+
44+
### Install subsites creator
45+
sudo -E -u www-data drush si --account-pass=admin -y && drush en bc_subsites admin_toolbar_tools -y
46+
47+
48+
### Entironments variables
49+
50+
Define your .env file as it stated below
51+
```
52+
#
53+
# Copy and rename this file to .env at root of this project.
54+
#
55+
56+
# Uncomment and populate as needed.
57+
## Subsite admin UI db creadentials
58+
MYSQL_DATABASE=os2subsites
59+
MYSQL_HOSTNAME=mariadb
60+
MYSQL_ROOT_PASSWORD=root
61+
MYSQL_PASSWORD=os2subsites
62+
MYSQL_PORT=3306
63+
MYSQL_USER=os2subsites
64+
65+
## Drupal salt
66+
DRUPAL_HASH_SALT=w-NR7Q2C3URQH6qdRvDPlbxVqdvyGMbsOwyXgtqkdJGNI7FBMbrD79UMx2DDNlSqvfmY-OOKLw
67+
## Domain suffix that would be used for subsites
68+
DOMAIN_SUFFIX=os2subsites.local
69+
## Path to base site config directory
70+
BASE_SUBSITE_CONFIG_DIR=/opt/drupal/config/ay-test0604-3.${DOMAIN_SUFFIX}/sync
71+
72+
# OS2SUBSITE common varaibles.
73+
## Flag for using environment variables
74+
## Comment this variale to use values from `config.sh file`
75+
USE_ENV_CONFIG=1
76+
## Drupal project root directory
77+
BASEDIR=/opt/drupal
78+
SERVERIP=127.0.0.1
79+
## Default Drupal profile for subsites.
80+
## Use `base_config` value
81+
PROFILE=base_config
82+
ALLOWED_INSTALL_PROFILES=minimal,os2web
83+
## Email used for subsite admin user.
84+
85+
## Path to
86+
SCRIPTDIR=/opt/drupal/scripts/os2subsites_provision
87+
## Path to drush
88+
DRUSH=/usr/local/bin/drush
89+
## Database creadentials for creating subsite db.
90+
DBHOST=mariadb
91+
DBUSER_HOST=mariadb
92+
### Optional varialbles. Leave it empty to user root as user name.
93+
DB_ROOT_USER=root
94+
### Optional varialbles. Leave it empty to user root user without password from localhost.
95+
DB_ROOT_PASSWORD=root
96+
## External db provisioning. NOTE: To disable external provisioning you have to JUST comment variable
97+
EXTERNAL_DB_PROVISIONING=1
98+
PROVISIONING_SOURCES_PATH=/opt/drupal/private/subsite-credentials
99+
## For internal db provisioning you have to specify directory to mysql db files are stored. It's used for db existing check.
100+
#DBDIR=/var/lib/mysql
101+
## Subsite admin pass
102+
ADMINPASS=admin
103+
## Path to subsite vhost template
104+
VHOSTTEMPLATE=${SCRIPTDIR}/../os2subsites_provision/os2subsites-vhost-template
105+
## Drupal document root directory path
106+
MULTISITE=${BASEDIR}/web
107+
## Path to file where subsites registering.
108+
SITESFILE=${MULTISITE}/sites/sites.php
109+
## Temp directory for subsites
110+
TMPDIRBASE=${BASEDIR}/tmp
111+
## Log directory for subsites
112+
LOGDIRBASE=${BASEDIR}/logs
113+
## Session directory for subsites
114+
SESSIONDIRBASE=${BASEDIR}/sessions
115+
## Username for subsite administrator user. User will be created on subsites.
116+
SITEADMIN=subsiteadmin
117+
## Apache webserver username.
118+
APACHEUSER=www-data
119+
## Root user name. Sometimes this variable is empty.
120+
USER=root
121+
# Version of Drupal core. Accepted values 7,8
122+
DRUPAL=8
123+
# Additional option for site-install command
124+
INSTALL_OPTIONS=
125+
126+
## Variable used only in docker-compose.yaml
127+
COMPOSE_PROJECT_NAME=os2web-subsites-docker-compose
128+
TAG=2.1.5-rc-BKDK-521 # <---- This value should be one you use for testing.
129+
WEB_SERVER_PORT=8098
130+
```
131+
132+
### Handling domains
133+
134+
Main domain for subsite creator is localhost:8098
135+
136+
NOTE: Port could be different if you changed `WEB_SERVER_PORT` variable.
137+
138+
Each subsites domain should be defined in your local `/etc/hosts` file like:
139+
```
140+
127.0.0.1 new-subsite.os2subsites.local
141+
```
142+
143+
NOTE: Domain suffix `.os2subsites.local` could be different if you changed `DOMAIN_SUFFIX` variable.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<VirtualHost *:80>
2+
<Directory /opt/drupal>
3+
AllowOverride All
4+
Options FollowSymLinks
5+
</Directory>
6+
7+
ServerAdmin [email protected]
8+
DocumentRoot /var/www/html
9+
10+
ErrorLog ${APACHE_LOG_DIR}/error.log
11+
CustomLog ${APACHE_LOG_DIR}/access.log combined
12+
13+
SetEnvIf X-Forwarded-Proto https HTTPS=on
14+
15+
php_admin_value open_basedir /opt/drupal:/usr/share/php
16+
php_value include_path .:/opt/drupal
17+
18+
php_value log_errors 1
19+
php_value html_errors 0
20+
php_value display_errors 0
21+
php_admin_value error_reporting 1023
22+
php_value error_log /dev/stderr
23+
24+
php_value session.save_path /opt/drupal/sessions
25+
php_admin_value upload_max_filesize 128M
26+
php_admin_value post_max_size 128M
27+
php_admin_value upload_tmp_dir /opt/drupal/tmp/default
28+
</VirtualHost>

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

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
</Directory>
7+
8+
ServerAdmin [email protected]
9+
DocumentRoot /var/www/html
10+
ServerName [domain]
11+
12+
CustomLog ${APACHE_LOG_DIR}/access.log combined
13+
ErrorLog ${APACHE_LOG_DIR}/error.log
14+
15+
php_admin_value open_basedir [basedir]:/usr/share/php
16+
php_value include_path .:[basedir]
17+
php_value error_log /dev/stderr
18+
php_value session.save_path [basedir]/sessions/[domain]
19+
php_admin_value upload_tmp_dir [basedir]/tmp/[domain]
20+
21+
php_value log_errors 1
22+
php_value html_errors 0
23+
php_value display_errors 0
24+
php_admin_value error_reporting 2047
25+
php_admin_value max_execution_time 180
26+
</VirtualHost>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ networks:
99
volumes:
1010
mysql:
1111
driver: local
12-
os2web:
13-
driver: local
1412
services:
1513

1614
# General application container.
@@ -22,10 +20,12 @@ services:
2220
- ./logs:/var/log:delegated
2321
- ./volumes/drupal/private:/opt/drupal/private
2422
- ./volumes/drupal/web/sites:/opt/drupal/web/sites
25-
- ./volumes/apache/sites-availbale:/etc/apache/sites-availbale
26-
- ./volumes/apache/sites-enabled:/etc/apache/sites-enabled
23+
- ./volumes/apache2/sites-available:/etc/apache2/sites-available
24+
- ./volumes/apache2/sites-enabled:/etc/apache2/sites-enabled
2725
- ./volumes/config:/opt/drupal/config
2826
- ./volumes/crontabs:/var/spool/cron/crontabs
27+
- ./volumes/tmp:/opt/drupal/tmp
28+
#- ../../scripts/os2subsites_provision:/opt/drupal/scripts/os2subsites_provision
2929
depends_on:
3030
- mariadb
3131
ports:
@@ -39,8 +39,8 @@ services:
3939
mariadb:
4040
image: mariadb:latest
4141
volumes:
42-
- /var/lib/mysql
42+
- mysql:/var/lib/mysql
4343
networks:
4444
- backend
45-
environment:
46-
MARIADB_ROOT_PASSWORD: root
45+
env_file:
46+
- .env

.docker/os2web-subsites/entrypoint.sh

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

6+
# Check basic file structure for subsites creator
7+
if [ ! -f "/etc/apache2/sites-available/000-default.conf" ]
8+
then
9+
cp -f /opt/drupal/.docker/os2web-subsites/apache/000-default.conf /etc/apache2/sites-available/000-default.conf
10+
ln -sf /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/000-default.conf
11+
fi
12+
13+
# Check basic file structure for subsites creator
14+
if [ ! -d "/opt/drupal/web/sites/default" ]
15+
then
16+
echo "Default sites folder doesn't exists. Create folder and standard files"
17+
mkdir -p /opt/drupal/web/sites/default/files
18+
cp -f /opt/drupal/.docker/os2web-subsites/settings/default.settings.php /opt/drupal/web/sites/default/default.settings.php
19+
cp -f /opt/drupal/.docker/os2web-subsites/settings/default.settings.php /opt/drupal/web/sites/default/settings.php
20+
echo 'include $app_root . "/" . $site_path . "/settings.local.php";' >> /opt/drupal/web/sites/default/settings.php
21+
cp -f /opt/drupal/.docker/os2web-subsites/settings/settings.local.php /opt/drupal/web/sites/default/settings.local.php
22+
chmod 755 /opt/drupal/web/sites/default /opt/drupal/web/sites/default/settings.php /opt/drupal/web/sites/default/settings.local.php
23+
chown -R www-data:www-data /opt/drupal/web/sites
24+
fi
25+
26+
# Check basic file structure for subsites creator
27+
if [ ! -f "/opt/drupal/web/sites/sites.php" ]
28+
then
29+
echo "Creating web/sites/sites.php"
30+
echo "<?php" > /opt/drupal/web/sites/sites.php
31+
chown www-data:www-data /opt/drupal/web/sites/sites.php
32+
fi
33+
34+
# Check default config dir
35+
if [ ! -f "/opt/drupal/config/default" ]
36+
then
37+
mkdir -p /opt/drupal/config/default
38+
chown www-data:www-data -R /opt/drupal/config
39+
fi
40+
41+
# Check default temp dir
42+
if [ ! -f "/opt/drupal/tmp/default" ]
43+
then
44+
mkdir -p /opt/drupal/tmp/default
45+
chown www-data:www-data -R /opt/drupal/tmp
46+
fi
47+
48+
# Check default private dir
49+
if [ ! -f "/opt/drupal/private/default" ]
50+
then
51+
mkdir -p /opt/drupal/private/default
52+
chown www-data:www-data -R /opt/drupal/private
53+
fi
54+
55+
# Copying shared settings file
56+
cp -f /opt/drupal/.docker/os2web-subsites/settings/shared.settings.php /opt/drupal/web/sites/shared.settings.php
57+
658
exec "$@"

.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

0 commit comments

Comments
 (0)