Skip to content

Commit 821e290

Browse files
authored
Merge pull request #22 from OS2Forms/docker
Update docker-compose stack
2 parents d9b86f0 + c4cbf6c commit 821e290

File tree

19 files changed

+494
-762
lines changed

19 files changed

+494
-762
lines changed

.docker/apache/conf/httpd.conf

Lines changed: 0 additions & 553 deletions
This file was deleted.

.docker/apache/example.com.conf.template

Lines changed: 0 additions & 39 deletions
This file was deleted.

.docker/os2forms/Dockerfile

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
FROM drupal:8-apache-buster
2+
3+
# Installing additional dependencies.
4+
RUN set -eux; \
5+
apt update; \
6+
apt install -qq -y \
7+
libxml2-dev \
8+
libldap2-dev \
9+
git \
10+
wget \
11+
zip \
12+
mariadb-client-10.3 \
13+
cron; \
14+
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
15+
docker-php-ext-install soap ldap
16+
17+
# Removing standard Drupal core and loading OS2Web project.
18+
WORKDIR /opt
19+
# Getting recent state of master branch.
20+
ARG OS2FORMS8_TAG
21+
RUN set -eux; \
22+
rm -rf drupal; \
23+
# PRODUCTION SETTINGS
24+
# Loading OS2Forms via tags.
25+
# wget https://github.com/os2forms/os2forms8/archive/$OS2FORMS8_TAG.tar.gz; \
26+
# tar -xzvf $OS2FORMS8_TAG.tar.gz; \
27+
# rm $OS2FORMS8_TAG.tar.gz; \
28+
# mv os2forms8-$OS2FORMS8_TAG drupal
29+
# DEVELOPMENT SETTINGS
30+
# Loading OS2Forms from branch to avoid development releases.
31+
wget https://github.com/OS2Forms/os2forms8/archive/docker.zip; \
32+
unzip docker.zip; \
33+
rm docker.zip; \
34+
mv os2forms8-docker drupal
35+
WORKDIR /opt/drupal
36+
37+
# Loading composer dependencies and configuring project folders.
38+
RUN set -eux; \
39+
composer self-update --1; \
40+
export COMPOSER_HOME="$(mktemp -d)"; \
41+
composer global require hirak/prestissimo;\
42+
COMPOSER_MEMORY_LIMIT=-1 composer install; \
43+
chown -R www-data:www-data web/sites web/modules web/themes; \
44+
# delete composer cache.
45+
rm -rf "$COMPOSER_HOME"
46+
47+
# Adding further site specific data to image.
48+
RUN mkdir -p files; \
49+
mkdir -p private; \
50+
mkdir -p config/sync; \
51+
mkdir -p tmp; \
52+
rm -rf /opt/drupal/web/sites/default/files; \
53+
ln -sf /opt/drupal/files /opt/drupal/web/sites/default/files; \
54+
# Adjusting ownership
55+
chown -R www-data:www-data /opt/drupal/private /opt/drupal/files /opt/drupal/config/sync /opt/drupal/tmp /opt/drupal/logs; \
56+
chmod g+s -R /opt/drupal/private /opt/drupal/files /opt/drupal/config/sync
57+
58+
# Adding custom apache configuration with PHP value and log settings.
59+
COPY apache/000-default.conf /etc/apache2/sites-enabled/000-default.conf
60+
61+
# Adding Drupal settings.
62+
COPY drupal/settings.local.php /opt/drupal/web/sites/default/

.docker/os2forms/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# OS2Forms8 docker image
2+
3+
Purpose of this image to run OS2Forms8 project in dockerized environment.
4+
5+
Image based on official [Drupal image](https://hub.docker.com/_/drupal)
6+
7+
Image includes all functional project files inside (PHP code, Composer dependencies).
8+
9+
Drupal content files should be attached as [Volumes](https://docs.docker.com/storage/volumes/) to container:
10+
* public files - `/opt/drupal/files`
11+
* private files - `/opt/drupal/private`
12+
13+
## Environment settings
14+
15+
There are available following environment settings:
16+
17+
### Mysql database
18+
* MYSQL_HOSTNAME - mysql service host name
19+
* MYSQL_DATABASE - mysql service database name
20+
* MYSQL_PORT - mysql service port
21+
* MYSQL_USER - mysql service user
22+
* MYSQL_PASSWORD - mysql service password
23+
24+
### Drupal
25+
* DRUPAL_HASH_SALT - define drupal hash salt. Uses in `settings.php` file
26+
27+
## Build image
28+
29+
To build image use `build.sh` script with git tag of OS2Forms8 project release as first argument.
30+
NOTE: You should have existing tag for OS2Web project before.
31+
32+
Example:
33+
```
34+
./build.sh [tag-name] --push
35+
```
36+
37+
`--push` - when you this option build will be pushed to docker hub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<VirtualHost *:80>
2+
# There is no host restriction here.
3+
# Restriction should be implemented on upper levels.
4+
#ServerName example.com
5+
ServerAdmin webmaster@localhost
6+
DocumentRoot /var/www/html
7+
8+
ErrorLog ${APACHE_LOG_DIR}/error.log
9+
CustomLog ${APACHE_LOG_DIR}/access.log combined
10+
11+
# SimpleSAMLphp settings
12+
SetEnv SIMPLESAMLPHP_CONFIG_DIR /opt/drupal/simplesamlphp/config
13+
Alias /simplesaml /opt/drupal/vendor/simplesamlphp/simplesamlphp/www
14+
<Directory /opt/drupal/vendor/simplesamlphp/simplesamlphp/www>
15+
Require all granted
16+
</Directory>
17+
18+
19+
# PHP Custom settings
20+
php_admin_value open_basedir /opt/drupal:/usr/share/php
21+
php_value include_path .:/opt/drupal
22+
php_value log_errors 1
23+
php_value html_errors 0
24+
php_value display_errors 0
25+
php_admin_value error_reporting 1023
26+
php_value error_log /dev/stderr
27+
php_value session.save_path /opt/drupal/sessions
28+
php_admin_value upload_max_filesize 150
29+
php_admin_value upload_tmp_dir /opt/drupal/tmp
30+
</VirtualHost>

.docker/os2forms/build.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
if [ $# -eq 0 ]; then
4+
echo "WARNING: There was no tag-name provided!"
5+
echo "Script usage is: './build.sh tag-name'"
6+
echo "Example: './build.sh 1.0.3'"
7+
exit 0
8+
fi
9+
10+
echo "Updating base image"
11+
docker image pull drupal:8-apache-buster
12+
13+
echo "Building OS2Forms image with tag $1"
14+
docker build ./ --build-arg OS2FORMS8_TAG=$1 -t os2forms/os2forms8:$1
15+
16+
if [ "$2" = "--push" ]; then
17+
echo "Authorization to https://hub.docker.com. :"
18+
echo "Login:"
19+
read -s DOCKERHUB_LOGIN
20+
echo "Password:"
21+
read -s DOCKERHUB_PASS
22+
echo "Authorization..."
23+
echo $DOCKERHUB_PASS | docker login --username $DOCKERHUB_LOGIN --password-stdin
24+
25+
if [ $? -eq 0 ]; then
26+
echo "Pushing image to docker hub ..."
27+
docker push os2forms/os2forms8:$1
28+
echo "Check your image here https://hub.docker.com/repository/docker/os2forms/os2forms8"
29+
else
30+
echo "Image is not pushed to docker hub :("
31+
fi;
32+
fi;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$databases['default']['default'] = [
4+
'database' => getenv('MYSQL_DATABASE'),
5+
'driver' => 'mysql',
6+
'host' => getenv('MYSQL_HOSTNAME'),
7+
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
8+
'password' => getenv('MYSQL_PASSWORD'),
9+
'port' => getenv('MYSQL_PORT'),
10+
'prefix' => '',
11+
'username' => getenv('MYSQL_USER'),
12+
];
13+
14+
$settings['hash_salt'] = getenv('DRUPAL_HASH_SALT');
15+
$settings['trusted_host_patterns'] = empty(getenv('DRUPAL_TRUSTED_HOST')) ? NULL : ['^'.getenv('DRUPAL_TRUSTED_HOST').'$'];
16+
17+
$settings['config_sync_directory'] = '../config/sync';
18+
$settings['file_temp_path'] = '../tmp';
19+
$settings['file_private_path'] = '../private';
File renamed without changes.

.docker/php/Dockerfile

Lines changed: 0 additions & 48 deletions
This file was deleted.

.docker/php/custom.ini

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)