diff --git a/.gitignore b/.gitignore index 4083037..cf19cb6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ local +.idea/ +testrail-*.zip diff --git a/Dockerfile b/Dockerfile index b05681e..26dfb48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,33 @@ -FROM ubuntu:trusty +FROM php:7.2.16-apache-stretch -RUN apt-get update && apt-get install -y --no-install-recommends \ - php5 php5-cli php5-mysql php5-curl \ - mysql-server \ - curl \ - unzip \ - && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y \ + unzip \ + cron \ + supervisor -RUN curl -O http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64_5.1.2.tar.gz && \ - tar vxfz ioncube_loaders_lin_*.tar.gz && \ +RUN docker-php-ext-install mysqli + +RUN mkdir /ioncube && \ + curl -O https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && \ + tar vxfz ioncube_loaders_lin_*.tar.gz -C / && \ rm -f ioncube_loaders_lin_*.tar.gz -RUN echo "zend_extension=/ioncube/ioncube_loader_lin_5.5.so" > /etc/php5/cli/php.ini.new && \ - cat /etc/php5/cli/php.ini >> /etc/php5/cli/php.ini.new && \ - mv /etc/php5/cli/php.ini.new /etc/php5/cli/php.ini && \ - echo "zend_extension=/ioncube/ioncube_loader_lin_5.5.so" > /etc/php5/apache2/php.ini.new && \ - cat /etc/php5/apache2/php.ini >> /etc/php5/apache2/php.ini.new && \ - mv /etc/php5/apache2/php.ini.new /etc/php5/apache2/php.ini +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + +RUN echo "zend_extension=/ioncube/ioncube_loader_lin_7.2.so" >> $PHP_INI_DIR/php.ini COPY testrail-*.zip / RUN cd /var/www/html && unzip -q /testrail-*.zip COPY config.php /var/www/html/testrail/config.php -COPY testrail.sql / -COPY run.sh / -CMD /run.sh +RUN mkdir /var/www/html/testrail/logs && \ +chown www-data /var/www/html/testrail/logs + +RUN echo '* * * * * www-data php /var/www/html/testrail/task.php' >> /etc/crontab + +EXPOSE 80 + +ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +ENTRYPOINT ["/usr/bin/supervisord"] \ No newline at end of file diff --git a/README.md b/README.md index 880917d..bcb29e2 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,12 @@ Run [TestRail](http://www.gurock.com/testrail/) in a Docker container, for testi ## Prerequisites -1. Download your version of TestRail from their website, and put it in the current directory (e.g. `testrail-5.3.0.3603-ion53.zip`). +1. Download your version of TestRail from their website, and put it in the current directory (e.g. `testrail-5.6.x-ion53.zip`). 1. Have your TestRail license key ready. You will need it later. This repository includes a minimal database dump (`testrail.sql`) that can be used as a starting point. -If you want to use your own data, you can dump your existing TestRail database server and replace `testrail.sql` with the contents. -For example: - - mysqldump testrail > testrail.sql +If you want to use your own data, you can dump your existing TestRail database server and replace `data/testrail.sql` with the contents. +See mysql image documentation about data import for more. ## Build the Image @@ -19,17 +17,20 @@ To build the image: docker build -t testrail . -## Run the Container +## Run the Container - ./start_container.sh + docker-compose up ## Usage Browse to: - http://localhost:7070/testrail/ + http://localhost:8123/testrail/ To log in: - Email address: `admin@admin.com` - Password: `admin` + +Problems: +- migrate existing assets (screenshots, reports?) located in same dir where testrail code diff --git a/config.php b/config.php index 41fb6b8..c9caa49 100644 --- a/config.php +++ b/config.php @@ -11,7 +11,7 @@ */ define('DB_DRIVER', 'mysql'); // sqlsrv or mysql -define('DB_HOSTNAME', 'localhost'); +define('DB_HOSTNAME', 'mysql'); define('DB_DATABASE', 'testrail'); define('DB_USERNAME', 'testrail'); define('DB_PASSWORD', 'newpassword'); diff --git a/testrail.sql b/data/testrail.sql similarity index 100% rename from testrail.sql rename to data/testrail.sql diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..21fc7de --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3.5' +services: + mysql: + container_name: mysql + image: mysql/mysql:5.5.60 + ports: + - "3306:3306" + volumes: + - ./data:/docker-entrypoint-initdb.d + environment: + - MYSQL_USER=testrail + - MYSQL_PASSWORD=newpassword + - MYSQL_ROOT_PASSWORD=newpassword + - MYSQL_DATABASE=testrail + testrail: + container_name: testrail + image: testrail:latest + ports: + - "8123:80" +# links: +# - mysql diff --git a/run.sh b/run.sh deleted file mode 100755 index 7a2f572..0000000 --- a/run.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -e - -mkdir /var/www/html/testrail/logs -chown www-data /var/www/html/testrail/logs - -echo '* * * * * www-data /usr/bin/php /var/www/html/testrail/task.php' > /etc/cron.d/testrail - -/etc/init.d/mysql start - -echo "CREATE DATABASE testrail DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;" | mysql -u root -echo "CREATE USER 'testrail'@'localhost' IDENTIFIED BY 'newpassword';" | mysql -u root -echo "GRANT ALL ON testrail.* TO 'testrail'@'localhost';" | mysql -u root - -mysql testrail < testrail.sql - -/etc/init.d/apache2 start -sleep infinity diff --git a/start_container.sh b/start_container.sh deleted file mode 100755 index 3b54496..0000000 --- a/start_container.sh +++ /dev/null @@ -1 +0,0 @@ -docker run --name testrail -d -p 7070:80 testrail diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 0000000..e34c6d3 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,8 @@ +[supervisord] +nodaemon=true + +[program:cron] +command=cron -f + +[program:apache2] +command=apache2-foreground \ No newline at end of file