Commit 425d8496 authored by Son Nguyen's avatar Son Nguyen

Add docker images for mahara developers and testers

Change-Id: I9b9586dd3567f59f52ac765842a4e1e44203a5a5
parent 20ab5802
FROM centos:6.7
MAINTAINER http://www.centos.org
LABEL Vendor="CentOS"
LABEL License=GPLv2
RUN yum -y update && yum clean all
RUN yum -y install httpd mod_ssl\
php\
php-cli\
curl\
php-pgsql \
php-mysql \
php-gd \
php-curl \
php-xml \
&& yum clean all
EXPOSE 80
# Simple startup script to avoid some issues observed with container restart
ADD run-httpd.sh /run-httpd.sh
RUN chmod -v +x /run-httpd.sh
CMD ["/run-httpd.sh"]
#!/bin/bash
# Make sure we're not confused by old, incompletely-shutdown httpd
# context after restarting the container. httpd won't start correctly
# if it thinks it is already running.
rm -rf /run/httpd/* /tmp/httpd*
exec /usr/sbin/apachectl -DFOREGROUND
FROM debian:6.0
MAINTAINER Son Nguyen <son.nguyen@catalyst.net.nz>
#VOLUME ["/var/www/html"]
#VOLUME ["/var/lib/sitedata"]
RUN echo "deb http://archive.debian.org/debian/ squeeze main contrib" > /etc/apt/sources.list
RUN apt-get update && \
apt-get -y install \
sudo \
cron \
apache2 \
php5 \
php5-cli\
curl\
libapache2-mod-php5 \
php5-pgsql \
php5-mysql \
php5-gd \
php5-curl \
php5-json \
php5-ldap \
php5-xmlrpc \
php5-memcache\
php5-xdebug \
apt-utils \
debconf-utils
RUN echo "mysql-server-5.1 mysql-server/root_password password mahara" | debconf-set-selections
RUN echo "mysql-server-5.1 mysql-server/root_password_again password mahara" | debconf-set-selections
RUN apt-get -y install mysql-server
RUN apt-get clean
COPY ./apache2/default /etc/apache2/sites-available/default
COPY run /usr/local/bin/
RUN chmod +x /usr/local/bin/run
RUN a2enmod rewrite
EXPOSE 80
CMD ["/usr/local/bin/run"]
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /dev/stdout
CustomLog /dev/stdout combined
</VirtualHost>
create database `mahara-db` character set UTF8;
create user `maharauser`@localhost IDENTIFIED BY 'mahara';
grant all on `mahara-db`.* to `maharauser`@localhost IDENTIFIED BY 'mahara'
#!/bin/bash
set -e
sudo -u www-data mkdir -p /var/lib/sitedata/${MAHARA_CODEPATH}
echo -e "* * * * * www-data php /var/www/html/${MAHARA_CODEPATH}/htdocs/lib/cron.php >> /var/lib/sitedata/${MAHARA_CODEPATH}/cron.log 2>&1\n" > /etc/cron.d/mahara
chmod 0644 /etc/cron.d/mahara
cron
PHP_ERROR_REPORTING=${PHP_ERROR_REPORTING:-"E_ALL & ~E_DEPRECATED & ~E_NOTICE"}
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/apache2/php.ini
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/cli/php.ini
sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/apache2/php.ini
sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/cli/php.ini
echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/apache2/php.ini
echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/cli/php.ini
echo "xdebug.remote_enable=on" >> /etc/php5/apache2/conf.d/xdebug.ini
echo "xdebug.remote_connect_back=on" >> /etc/php5/apache2/conf.d/xdebug.ini
service mysql start
service mysql status
mysql -u root -pmahara -e 'create database `mahara-db` character set utf8'
mysql -u root -pmahara -e 'create user `maharauser`@localhost IDENTIFIED BY "mahara"'
mysql -u root -pmahara -e 'grant all on `mahara-db`.* to `maharauser`@localhost IDENTIFIED BY "mahara"'
source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND
FROM debian:jessie
MAINTAINER Son Nguyen <son.nguyen@catalyst.net.nz>
#VOLUME ["/var/www/html"]
#VOLUME ["/var/lib/sitedata"]
RUN apt-get update && \
apt-get -y install \
sudo \
cron \
apache2 \
php5 \
php5-cli\
curl\
libapache2-mod-php5 \
php5-pgsql \
php5-mysql \
php5-gd \
php5-curl \
php5-json \
php5-ldap \
php5-xmlrpc \
php5-memcache\
php5-xdebug \
apt-utils \
debconf-utils
RUN echo "mysql-server-5.5 mysql-server/root_password password mahara" | debconf-set-selections
RUN echo "mysql-server-5.5 mysql-server/root_password_again password mahara" | debconf-set-selections
RUN apt-get -y install mysql-server
RUN apt-get clean
COPY ./apache2/default /etc/apache2/sites-available/default
COPY run /usr/local/bin/
RUN chmod +x /usr/local/bin/run
RUN a2enmod rewrite
EXPOSE 80
CMD ["/usr/local/bin/run"]
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /dev/stdout
CustomLog /dev/stdout combined
</VirtualHost>
create database `mahara-db` character set UTF8;
create user `maharauser`@localhost IDENTIFIED BY 'mahara';
grant all on `mahara-db`.* to `maharauser`@localhost IDENTIFIED BY 'mahara'
#!/bin/bash
set -e
sudo -u www-data mkdir -p /var/lib/sitedata/${MAHARA_CODEPATH}
echo -e "* * * * * www-data php /var/www/html/${MAHARA_CODEPATH}/htdocs/lib/cron.php >> /var/lib/sitedata/${MAHARA_CODEPATH}/cron.log 2>&1\n" > /etc/cron.d/mahara
chmod 0644 /etc/cron.d/mahara
cron
PHP_ERROR_REPORTING=${PHP_ERROR_REPORTING:-"E_ALL & ~E_DEPRECATED & ~E_NOTICE"}
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/apache2/php.ini
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/cli/php.ini
sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/apache2/php.ini
sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/cli/php.ini
echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/apache2/php.ini
echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/cli/php.ini
echo "xdebug.remote_enable=on" >> /etc/php5/apache2/conf.d/xdebug.ini
echo "xdebug.remote_connect_back=on" >> /etc/php5/apache2/conf.d/xdebug.ini
service mysql start
service mysql status
mysql -u root -pmahara -e 'create database `mahara-db` character set utf8'
mysql -u root -pmahara -e 'create user `maharauser`@localhost IDENTIFIED BY "mahara"'
mysql -u root -pmahara -e 'grant all on `mahara-db`.* to `maharauser`@localhost IDENTIFIED BY "mahara"'
source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND
#!/bin/bash
set -e
# This will launch a mahara site on a docker container
# Mahara code and dataroot must be mapped from the host machine
if [ $# -lt 4 ]; then
echo -e "Launch a mahara site on the docker container\n\
\n\
Usage: $0 <nameofcontainer> <port> <pathtomaharacode> <pathtomaharadataroot> [<docker image>] \n\
For example: $0 maharasite01 8080 /home/user/code/mahara /home/user/maharadataroot\n\
You can then access the mahara site via http://localhost:8080/ on the host machine\n\
\n\
The default docker image is 'cat-prod-dockerregistry.catalyst.net.nz/sonn/mahara-dev:trusty64-apache24-php55-postgres-firefox45'\n"
exit 1;
fi
# Usage: ensure_webserver_running <url>
function ensure_webserver_running {
for i in `seq 1 15`; do
sleep 1
if curl --output /dev/null --silent --head --fail "$1"; then
return 0;
fi
done
return 1;
}
CONTAINERNAME=$1
PORT=$2
CODEROOT=$3
DATAROOT=$4
DOCKERIMAGE="cat-prod-dockerregistry.catalyst.net.nz/sonn/mahara-dev:trusty64-apache24-php55-postgres-firefox45"
if [ -n "$5" ]; then
echo -en "Checking if the docker image '$5' is available ..."
if [[ "$(sudo docker images -q $5 2> /dev/null)" == "" ]]; then
echo "FAILED"
else
DOCKERIMAGE=$5
echo "OK"
fi
fi
echo "The docker image '$DOCKERIMAGE' will be used"
# Check we are not running as root for some weird reason
if [[ "$USER" = "root" ]]; then
echo "This script should not be run as root"
exit 1
fi
DOCKEROPTIONS=""
CONTAINERID=`sudo docker ps -a -f name=$CONTAINERNAME -q`
if [ "$CONTAINERID" != "" ]; then
if [[ "$(sudo docker ps -f name=$CONTAINERNAME -q)" != "" ]]; then
echo -e "FAILED\n\
The container '$CONTAINERNAME' is running\n\
Run: stop_mahara_container.sh $CONTAINERNAME to stop it\n"
exit 2
else
sudo docker rm $CONTAINERID > /dev/null 2>&1
fi
fi
DOCKEROPTIONS="$DOCKEROPTIONS --name $CONTAINERNAME"
echo -en "Checking if $PORT is in use ..."
if sudo netstat -an | grep "$PORT" | grep "LISTEN" > /dev/null 2>&1; then
echo -e "FAILED\n\
The port '$PORT' is already in use by another application\n"
exit 2
fi
DOCKEROPTIONS="$DOCKEROPTIONS -p $PORT:80"
echo "OK"
echo -en "Checking mahara code ..."
if sudo -u www-data test -r $CODEROOT/htdocs/index.php; then
echo "OK"
DOCKEROPTIONS="$DOCKEROPTIONS -v $CODEROOT:/var/www:ro"
if [ ! -f $CODEROOT/htdocs/theme/raw/style/style.css ]; then
echo "Generate CSS files for themes and install other required software"
make -C $CODEROOT all
fi
if [ ! -f $CODEROOT/external/composer.lock ]; then
echo "Install/Update PHP Composer and all other required software"
make -C $CODEROOT initcomposer
fi
SELENIUM_VERSION_MAJOR=2.53
SELENIUM_VERSION_MINOR=1
SELENIUM_FILENAME=selenium-server-standalone-$SELENIUM_VERSION_MAJOR.$SELENIUM_VERSION_MINOR.jar
SELENIUM_PATH=$CODEROOT/test/behat/$SELENIUM_FILENAME
if [ ! -f $SELENIUM_PATH ]; then
echo -en "Downloading Selenium server ..."
wget -q -O $SELENIUM_PATH http://selenium-release.storage.googleapis.com/$SELENIUM_VERSION_MAJOR/$SELENIUM_FILENAME
echo "Done"
fi
else
echo -e "FAILED\n\
Can not read the mahara code\n\
Please make sure the directory '$CODEROOT' containing the mahara directory 'htdocs' and readable by user 'www-data'\n"
exit 3
fi
echo -en "Checking mahara dataroot ..."
if sudo -u www-data test -w $DATAROOT; then
DOCKEROPTIONS="$DOCKEROPTIONS -v $DATAROOT:/var/lib/sitedata"
echo "OK"
else
echo -e "FAILED\n\
Can not read and write the mahara dataroot '$DATAROOT'\n\
Please make sure the directory '$DATAROOT' writable by user 'www-data'\n"
exit 4
fi
echo -en "Starting the container ..."
sudo docker run -d $DOCKEROPTIONS $DOCKERIMAGE run $PORT > /dev/null 2>&1
# Wait until the site is available
ensure_webserver_running http://localhost:$PORT/
echo "Done"
echo "You can now access the mahara site at http://localhost:$PORT/"
#!/bin/bash
set -e
# This script will run behat tests for mahara on a given docker container
if [ $# -lt 2 ]; then
echo -e "Run behat tests for mahara on a given docker container\n\
Usage: $0 <container name> <action> [tag name|feature file]\n\
For example: $0 mahara_container01 run\n\
Run all behat tests on the container: mahara_container01"
fi
function cleanup {
sudo docker exec $CONTAINERNAME run_cleanup.sh
}
CONTAINERNAME=$1
echo -en "Checking if $CONTAINERNAME is running ..."
if [[ "$(sudo docker ps -q -f name=$CONTAINERNAME)" = "" ]]; then
echo -e "FAILED\n\
The container '$CONTAINERNAME' is not running\n"
exit 1
fi
echo "OK"
# Run the behat tests
shift
sudo docker exec -it $CONTAINERNAME run_tests.sh $*
#cleanup
exit 0
# Trap errors, user interrupts so we can cleanup
#trap cleanup ERR
#trap cleanup INT
#!/bin/bash
set -e
# This script will stop the given mahara container
if [ $# -ne 1 ]; then
echo -e "Stop the given mahara container\n\
Usage: $0 <container name>\n\
For example: $0 mahara_container01\n\
Stop the container: mahara_container01"
fi
CONTAINERNAME=$1
echo -en "Checking if $CONTAINERNAME is running ..."
if [[ "$(sudo docker ps -q -f name=$CONTAINERNAME)" = "" ]]; then
echo -e "FAILED\n\
The container '$CONTAINERNAME' is not running\n"
exit 1
fi
echo "OK"
# Stop the container
echo -en "Stopping the container $CONTAINERNAME ..."
sudo docker stop $CONTAINERNAME > /dev/null 2>&1
echo "Done"
FROM ubuntu:14.04
MAINTAINER Son Nguyen <ngson2000@yahoo.com>
RUN apt-get update && \
apt-get -y install \
sudo \
cron \
gzip \
apache2 \
php5 \
php5-cli\
curl\
git\
bzr\
libhtml-tiny-perl\
liblocale-po-perl\
libwww-perl && \
apt-get clean
EXPOSE 80
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
AllowOverride All
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog /dev/stdout
CustomLog /dev/stdout combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
#!/bin/bash
set -e
sudo -u www-data mkdir -p /var/lib/sitedata/${MAHARA_CODEPATH}
echo -e "* * * * * www-data php /var/www/html/${MAHARA_CODEPATH}/htdocs/lib/cron.php >> /var/lib/sitedata/${MAHARA_CODEPATH}/cron.log 2>&1\n" > /etc/cron.d/mahara
chmod 0644 /etc/cron.d/mahara
cron
PHP_ERROR_REPORTING=${PHP_ERROR_REPORTING:-"E_ALL & ~E_DEPRECATED & ~E_NOTICE"}
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/apache2/php.ini
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/cli/php.ini
sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/apache2/php.ini
sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/cli/php.ini
echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/apache2/php.ini
echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/cli/php.ini
echo "xdebug.remote_enable=on" >> /etc/php5/apache2/conf.d/xdebug.ini
echo "xdebug.remote_connect_back=on" >> /etc/php5/apache2/conf.d/xdebug.ini
source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND
FROM ubuntu:14.04
MAINTAINER Son Nguyen <son.nguyen@catalyst.net.nz>
# trusty64, Apache 2.4, Php 5.5, PostgreSQL 9.3, Xvfb, Firefox 45
# This will be used for running behat tests
VOLUME ["/var/www"]
VOLUME ["/var/lib/sitedata"]
RUN apt-get update && \
apt-get -y install software-properties-common
RUN add-apt-repository universe
RUN apt-get update && \
apt-get -y install \
sudo \
sendmail \
memcached \
cron \
curl\
apache2\
php5 \
php5-cli\
libapache2-mod-php5\
php5-pgsql \
php5-pgsql \
php5-gd \
php5-curl \
php5-json \
php5-ldap \
php5-xmlrpc \
php5-mcrypt \
php5-memcache\
php5-xdebug\
php5-mysql
RUN apt-get -y install postgresql postgresql-contrib
RUN apt-get -y install openjdk-7-jre xvfb
RUN apt-get clean
# Install Firefox 45.0.2 64bit
ADD firefox-45.0.2.tar.bz2 /usr/local/
RUN ln -s /usr/local/firefox/firefox /usr/bin/firefox
RUN rm -rf /var/www/html
ADD run* /usr/local/bin/
RUN chmod +x /usr/local/bin/run*
EXPOSE 80
#!/bin/bash
set -e
# This script will launch a fresh mahara site on the docker container
# The mahara code and dataroot folder must be mapped from the host
if [ $# -ne 1 ]; then
echo -e "Launch a fresh mahara site on the docker container\n\
Usage: $0 <port>\n"
exit 1;
fi
PORT=$1
# PHP settings for mahara
PHP_ERROR_REPORTING=${PHP_ERROR_REPORTING:-"E_ALL & ~E_DEPRECATED & ~E_NOTICE"}
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/apache2/php.ini
sed -ri 's/^display_errors\s*=\s*Off/display_errors = On/g' /etc/php5/cli/php.ini
sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/apache2/php.ini
sed -ri "s/^error_reporting\s*=.*$//g" /etc/php5/cli/php.ini
echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/apache2/php.ini
echo "error_reporting = $PHP_ERROR_REPORTING" >> /etc/php5/cli/php.ini
sed -ri "s/^post_max_size\s*=.*$/post_max_size = 32M/g" /etc/php5/apache2/php.ini
sed -ri "s/^post_max_size\s*=.*$/post_max_size = 32M/g" /etc/php5/cli/php.ini
# Uncomment to enable remote debugging
echo "xdebug.remote_enable=on" >> /etc/php5/apache2/conf.d/xdebug.ini
echo "xdebug.remote_connect_back=on" >> /etc/php5/apache2/conf.d/xdebug.ini
echo -e 'LANG=en_NZ.UTF-8\nLC_ALL=en_NZ.UTF-8\nLANGUAGE=en_NZ:en' > /etc/default/locale
locale-gen en_NZ en_NZ.UTF-8 > /dev/null 2>&1
dpkg-reconfigure locales > /dev/null 2>&1
# Setup mahara site
# 1. mahara code
# The mahara code must be available under the directory
# /var/www
if [ ! -f /var/www/htdocs/index.php ]; then
echo -e "Can not find the mahara code\n\
Please use the option -v to map the mahara code folder which has the folder 'htdocs' on the host machine to the docker\n\
e.g. docker run -v <path to mahara coderoot>:/var/www\n"
exit;
fi
# Update the apache2 default site configuration
sed -ri "s/html$/htdocs/g" /etc/apache2/sites-available/000-default.conf
# 2. dataroot
if ! sudo -u www-data test -w /var/lib/sitedata; then
echo -e "Can not access the dataroot\n\
Please use the option -v to map the mahara dataroot on the host machine to the docker\n\
and make sure it can be read and written by user www-data\n\
e.g. docker run -v <path to mahara dataroot>:/var/lib/sitedata\n"
exit;
fi
# 3. Postgres database
service postgresql start > /dev/null 2>&1
echo -en "Creating mahara database ..."
sudo -u postgres psql -c "CREATE USER maharauser WITH NOSUPERUSER NOCREATEDB NOCREATEROLE PASSWORD 'mahara'" > /dev/null 2>&1
sudo -u postgres createdb --template=template0 mahara-db -Omaharauser -EUTF8 > /dev/null 2>&1
echo -e " Done."
# 4 config.php
# Update the mahara config.php
echo -e "Please update the following settings in the file <path to mahara htdocs>/config.php\n\
\$cfg->dbtype = 'postgres8';\n\
\$cfg->dbhost = 'localhost';\n\
\$cfg->dbuser = 'maharauser';\n\
\$cfg->dbname = 'mahara-db';\n\
\$cfg->dbpass = 'mahara';\n\
\$cfg->wwwroot = 'http://localhost:$PORT/';\n\
\$cfg->dataroot = '/var/lib/sitedata';\n"
# 5. cron job
echo -e "* * * * * www-data php /var/www/htdocs/lib/cron.php >> /var/lib/sitedata/cron.log 2>&1\n" > /etc/cron.d/mahara
chmod 0644 /etc/cron.d/mahara
cron
# 6. Elastic search engine
#service elasticsearch start
# 7. memcache server
service memcached start
# 8. Apache web server
/usr/sbin/apache2ctl -D FOREGROUND
#!/bin/bash
# This script will clean up behat test environment on the given docker
# if the running tests is stopped by user
function cleanup {
echo "Shutdown Selenium"
curl -o /dev/null --silent http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
if [[ $1 ]]
then
exit $1
else
exit 255
fi
echo "Disable behat test environment"
php /var/www/htdocs/testing/frameworks/behat/cli/util.php -d
}
cleanup 0
#!/bin/bash
# This script will run behat tests for mahara on a docker container
# The mahara code directory must be mapped to /var/www on the docker
MAHARAROOT=/var/www
if [ ! -f $MAHARAROOT/htdocs/index.php ]; then
echo -e "Can not find the mahara code\n\
Please use the option -v to map the mahara code folder which has the folder 'htdocs' on the host machine to the docker\n\
e.g. docker run -v <path to mahara coderoot>:/var/www\n"
exit 1;
fi
# Get action
ACTION=$1
# Wait and check if the selenium server is running in maximum 15 seconds
function is_selenium_running {
for i in `seq 1 15`; do
sleep 1
res=$(curl -o /dev/null --silent --write-out '%{http_code}\n' http://localhost:4444/wd/hub/status)
if [ $res == "200" ]; then
return 0;
fi
done
return 1;
}
function cleanup {
echo "Shutdown Selenium"
curl -o /dev/null --silent http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
if [[ $1 ]]
then
exit $1
else
exit 255
fi
echo "Disable behat test environment"
sudo -u www-data php htdocs/testing/frameworks/behat/cli/util.php -d
}
cd $MAHARAROOT
# Trap errors, user interrupts so we can cleanup
trap cleanup ERR
trap cleanup INT
if [ "$ACTION" = "action" ]
then
# Wrap the util.php script
PERFORM=$2
sudo -u www-data php htdocs/testing/frameworks/behat/cli/util.php --$PERFORM
elif [ "$ACTION" = "run" -o "$ACTION" = 'rundebug' ]
then
if [[ $2 == @* ]]; then
TAGS=$2
echo "Only run tests with the tag: $TAGS"
elif [ $2 ]; then
if [[ $2 == */* ]]; then
FEATURE="test/behat/features/$2"
else
FEATURE=`find test/behat/features -name $2 | head -n 1`
fi
echo "Only run tests in file: $FEATURE"
else
echo "Run all tests"
fi
# Show behat settings to run tests on the docker
if [ ! -d /var/lib/sitedata/behat ]; then
echo "Create the behat dataroot folder: /var/lib/sitedata/behat"
sudo -u www-data mkdir /var/lib/sitedata/behat;
fi
echo -e "Please add these settings in the file <path to mahara htdocs>/config.php to run behat tests\n\
\$cfg->behat_dbprefix = 'behat_';\n\
\$cfg->behat_wwwroot = 'http://localhost/';\n\
\$cfg->behat_dataroot = '/var/lib/sitedata/behat';\n"