Skip to content

Commit

Permalink
Dockerfile to run in docker. Issue #6
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneMcC committed Feb 24, 2020
1 parent 413107d commit 5547ba6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM shanemcc/docker-apache-php-base:latest
MAINTAINER Shane Mc Cormack <dataforce@dataforce.org.uk>

COPY . /conspectus

RUN \
rm -Rfv /var/www/html && \
chown -Rfv www-data: /conspectus/ /var/www/ && \
ln -s /conspectus/public /var/www/html && \
cd /conspectus/ && \
mv config.php.example config.php && \
su www-data --shell=/bin/bash -c "cd /conspectus; /usr/bin/composer install"
echo "AliasMatch ^/resources/(.+?)/(.*) /conspectus/themes/\$1/resources/\$2" | tee /etc/apache2/conf-enabled/aliasmatch.conf && \
echo "<Directory /conspectus/themes/>" | tee /etc/apache2/conf-enabled/themes.conf && \
echo " Require all granted" | tee -a /etc/apache2/conf-enabled/themes.conf && \
echo "</Directory>" | tee -a /etc/apache2/conf-enabled/themes.conf

EXPOSE 80

ENTRYPOINT ["/conspectus/bin/dockerRun.sh"]
9 changes: 9 additions & 0 deletions bin/dockerRun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

CMD="${@}"
if [ "${CMD}" = "" ]; then
php /conspectus/bin/db.php && exec "apache2-foreground"
else
exec "$@"
fi;
15 changes: 10 additions & 5 deletions config.php.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?php

$config['SQL_USERNAME'] = 'assets';
$config['SQL_PASSWORD'] = 'asdfsdf';
$config['SQL_DATABASE'] = 'asset_tracker';
$config['SQL_HOSTNAME'] = 'localhost';
$config['SQL_PORT'] = 3306;
function getEnvOrDefault($var, $default) {
$result = getEnv($var);
return $result === FALSE ? $default : $result;
}

$config['SQL_USERNAME'] = getEnvOrDefault('SQL_USERNAME', 'assets');
$config['SQL_PASSWORD'] = getEnvOrDefault('SQL_PASSWORD', 'asdfsdf');
$config['SQL_DATABASE'] = getEnvOrDefault('SQL_DATABASE', 'asset_tracker');
$config['SQL_HOSTNAME'] = getEnvOrDefault('SQL_HOSTNAME', 'localhost');
$config['SQL_PORT'] = getEnvOrDefault('SQL_PORT', 3306);

0 comments on commit 5547ba6

Please sign in to comment.