File tree Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Expand file tree Collapse file tree 4 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM debian:9
2+
3+ ADD packages.sh /usr/sbin/docker-packages
4+ RUN docker-packages
5+
6+ ADD install.sh /usr/sbin/docker-install
7+ RUN docker-install
8+
9+ ADD run.sh /usr/sbin/docker-run
10+ CMD docker-run
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # install software
4+ cd /root; git clone https://github.com/mevdschee/php-crud-api.git
5+ # download phpunit 4.8 for PHP < 5.6
6+ cd php-crud-api; wget https://phar.phpunit.de/phpunit-4.8.phar -O phpunit.phar
7+ # copy dist config to config
8+ cp tests/Config.php.dist tests/Config.php
9+ # replace variables
10+ sed -i ' s/{{mysql_hostname}}/localhost/g' tests/Config.php
11+ sed -i ' s/{{mysql_username}}/php-crud-api/g' tests/Config.php
12+ sed -i ' s/{{mysql_password}}/php-crud-api/g' tests/Config.php
13+ sed -i ' s/{{mysql_database}}/php-crud-api/g' tests/Config.php
14+ sed -i ' s/{{pgsql_hostname}}/localhost/g' tests/Config.php
15+ sed -i ' s/{{pgsql_username}}/php-crud-api/g' tests/Config.php
16+ sed -i ' s/{{pgsql_password}}/php-crud-api/g' tests/Config.php
17+ sed -i ' s/{{pgsql_database}}/php-crud-api/g' tests/Config.php
18+ sed -i ' s/{{sqlite_hostname}}//g' tests/Config.php
19+ sed -i ' s/{{sqlite_username}}//g' tests/Config.php
20+ sed -i ' s/{{sqlite_password}}//g' tests/Config.php
21+ sed -i ' s/{{sqlite_database}}/tests\/sqlite.db/g' tests/Config.php
22+ # move comments
23+ sed -i ' s/\/\* Uncomment/\/\/ Uncomment/g' tests/Config.php
24+ sed -i " s/'SQLServer'/\/\* 'SQLServer'/g" tests/Config.php
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # ensure noninteractive is enabled for apt
4+ export DEBIAN_FRONTEND=noninteractive
5+ # update (upgrade should not be needed)
6+ apt-get -y update # && apt-get -y upgrade
7+ # install: php / mysql / postgres / sqlite / tools
8+ apt-get -y install \
9+ php-cli php-xml \
10+ mariadb-server mariadb-client php-mysql \
11+ postgresql php-pgsql \
12+ sqlite php-sqlite3 \
13+ git wget
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # make sure mysql can create socket and lock
4+ mkdir /var/run/mysqld && chmod 777 /var/run/mysqld
5+ # run mysql server
6+ nohup mysqld > /root/mysql.log 2>&1 &
7+ # wait for mysql to become available
8+ while ! mysqladmin ping -hlocalhost > /dev/null 2>&1 ; do
9+ sleep 1
10+ done
11+ # create database and user on mysql
12+ mysql -u root > /dev/null << 'EOF '
13+ CREATE DATABASE `php-crud-api` CHARACTER SET utf8 COLLATE utf8_general_ci;
14+ CREATE USER 'php-crud-api'@'localhost' IDENTIFIED BY 'php-crud-api';
15+ GRANT ALL PRIVILEGES ON `php-crud-api`.* TO 'php-crud-api'@'localhost' WITH GRANT OPTION;
16+ FLUSH PRIVILEGES;
17+ EOF
18+
19+ # run postgres server
20+ nohup su - -c " /usr/lib/postgresql/9.6/bin/postgres -D /etc/postgresql/9.6/main" postgres > /root/postgres.log 2>&1 &
21+ # wait for postgres to become available
22+ until su - -c " psql -U postgres -c '\q'" postgres > /dev/null 2>&1 ; do
23+ sleep 1;
24+ done
25+ # create database and user on postgres
26+ su - -c " psql -U postgres >/dev/null" postgres << 'EOF '
27+ CREATE USER "php-crud-api" WITH PASSWORD 'php-crud-api';
28+ CREATE DATABASE "php-crud-api";
29+ GRANT ALL PRIVILEGES ON DATABASE "php-crud-api" to "php-crud-api";
30+ \q
31+ EOF
32+
33+ # run the tests
34+ cd /root/php-crud-api
35+ git pull
36+ php phpunit.phar
You can’t perform that action at this time.
0 commit comments