add debian 8

This commit is contained in:
Maurits van der Schee 2017-08-09 00:42:47 +02:00
commit 8a7e81e00f
8 changed files with 164 additions and 0 deletions

View file

@ -0,0 +1,10 @@
FROM debian:8
ADD packages.sh /usr/sbin/docker-packages
RUN docker-packages
ADD install.sh /usr/sbin/docker-install
RUN docker-install
ADD run.sh /usr/sbin/docker-run
CMD docker-run

View file

@ -0,0 +1,24 @@
#!/bin/bash
# install software
cd /root; git clone https://github.com/mevdschee/php-crud-api.git
# download phpunit 4.8 for PHP < 5.6
cd php-crud-api; wget https://phar.phpunit.de/phpunit-4.8.phar -O phpunit.phar
# copy dist config to config
cp tests/Config.php.dist tests/Config.php
# replace variables
sed -i 's/{{mysql_hostname}}/localhost/g' tests/Config.php
sed -i 's/{{mysql_username}}/php-crud-api/g' tests/Config.php
sed -i 's/{{mysql_password}}/php-crud-api/g' tests/Config.php
sed -i 's/{{mysql_database}}/php-crud-api/g' tests/Config.php
sed -i 's/{{pgsql_hostname}}/localhost/g' tests/Config.php
sed -i 's/{{pgsql_username}}/php-crud-api/g' tests/Config.php
sed -i 's/{{pgsql_password}}/php-crud-api/g' tests/Config.php
sed -i 's/{{pgsql_database}}/php-crud-api/g' tests/Config.php
sed -i 's/{{sqlite_hostname}}//g' tests/Config.php
sed -i 's/{{sqlite_username}}//g' tests/Config.php
sed -i 's/{{sqlite_password}}//g' tests/Config.php
sed -i 's/{{sqlite_database}}/tests\/sqlite.db/g' tests/Config.php
# move comments
sed -i 's/\/\* Uncomment/\/\/ Uncomment/g' tests/Config.php
sed -i "s/'SQLServer'/\/\* 'SQLServer'/g" tests/Config.php

View file

@ -0,0 +1,13 @@
#!/bin/bash
# ensure noninteractive is enabled for apt
export DEBIAN_FRONTEND=noninteractive
# update (upgrade should not be needed)
apt-get -y update # && apt-get -y upgrade
# install: php / mysql / postgres / sqlite / tools
apt-get -y install \
php5-cli \
mariadb-server mariadb-client php5-mysql \
postgresql php5-pgsql \
sqlite php5-sqlite \
git wget

36
docker/debian8-mariadb/run.sh Executable file
View file

@ -0,0 +1,36 @@
#!/bin/bash
# make sure mysql can create socket and lock
mkdir /var/run/mysqld && chmod 777 /var/run/mysqld
# run mysql server
nohup mysqld > /root/mysql.log 2>&1 &
# wait for mysql to become available
while ! mysqladmin ping -hlocalhost >/dev/null 2>&1; do
sleep 1
done
# create database and user on mysql
mysql -u root >/dev/null << 'EOF'
CREATE DATABASE `php-crud-api` CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'php-crud-api'@'localhost' IDENTIFIED BY 'php-crud-api';
GRANT ALL PRIVILEGES ON `php-crud-api`.* TO 'php-crud-api'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EOF
# run postgres server
nohup su - -c "/usr/lib/postgresql/9.4/bin/postgres -D /etc/postgresql/9.4/main" postgres > /root/postgres.log 2>&1 &
# wait for postgres to become available
until su - -c "psql -U postgres -c '\q'" postgres >/dev/null 2>&1; do
sleep 1;
done
# create database and user on postgres
su - -c "psql -U postgres >/dev/null" postgres << 'EOF'
CREATE USER "php-crud-api" WITH PASSWORD 'php-crud-api';
CREATE DATABASE "php-crud-api";
GRANT ALL PRIVILEGES ON DATABASE "php-crud-api" to "php-crud-api";
\q
EOF
# run the tests
cd /root/php-crud-api
git pull
php phpunit.phar

10
docker/debian8/Dockerfile Normal file
View file

@ -0,0 +1,10 @@
FROM debian:8
ADD packages.sh /usr/sbin/docker-packages
RUN docker-packages
ADD install.sh /usr/sbin/docker-install
RUN docker-install
ADD run.sh /usr/sbin/docker-run
CMD docker-run

24
docker/debian8/install.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/bash
# install software
cd /root; git clone https://github.com/mevdschee/php-crud-api.git
# download phpunit 4.8 for PHP < 5.6
cd php-crud-api; wget https://phar.phpunit.de/phpunit-4.8.phar -O phpunit.phar
# copy dist config to config
cp tests/Config.php.dist tests/Config.php
# replace variables
sed -i 's/{{mysql_hostname}}/localhost/g' tests/Config.php
sed -i 's/{{mysql_username}}/php-crud-api/g' tests/Config.php
sed -i 's/{{mysql_password}}/php-crud-api/g' tests/Config.php
sed -i 's/{{mysql_database}}/php-crud-api/g' tests/Config.php
sed -i 's/{{pgsql_hostname}}/localhost/g' tests/Config.php
sed -i 's/{{pgsql_username}}/php-crud-api/g' tests/Config.php
sed -i 's/{{pgsql_password}}/php-crud-api/g' tests/Config.php
sed -i 's/{{pgsql_database}}/php-crud-api/g' tests/Config.php
sed -i 's/{{sqlite_hostname}}//g' tests/Config.php
sed -i 's/{{sqlite_username}}//g' tests/Config.php
sed -i 's/{{sqlite_password}}//g' tests/Config.php
sed -i 's/{{sqlite_database}}/tests\/sqlite.db/g' tests/Config.php
# move comments
sed -i 's/\/\* Uncomment/\/\/ Uncomment/g' tests/Config.php
sed -i "s/'SQLServer'/\/\* 'SQLServer'/g" tests/Config.php

13
docker/debian8/packages.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
# ensure noninteractive is enabled for apt
export DEBIAN_FRONTEND=noninteractive
# update (upgrade should not be needed)
apt-get -y update # && apt-get -y upgrade
# install: php / mysql / postgres / sqlite / tools
apt-get -y install \
php5-cli \
mysql-server mysql-client php5-mysql \
postgresql php5-pgsql \
sqlite php5-sqlite \
git wget

34
docker/debian8/run.sh Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
# run mysql server
nohup mysqld > /root/mysql.log 2>&1 &
# wait for mysql to become available
while ! mysqladmin ping -hlocalhost >/dev/null 2>&1; do
sleep 1
done
# create database and user on mysql
mysql -u root >/dev/null << 'EOF'
CREATE DATABASE `php-crud-api` CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'php-crud-api'@'localhost' IDENTIFIED BY 'php-crud-api';
GRANT ALL PRIVILEGES ON `php-crud-api`.* TO 'php-crud-api'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EOF
# run postgres server
nohup su - -c "/usr/lib/postgresql/9.4/bin/postgres -D /etc/postgresql/9.4/main" postgres > /root/postgres.log 2>&1 &
# wait for postgres to become available
until su - -c "psql -U postgres -c '\q'" postgres >/dev/null 2>&1; do
sleep 1;
done
# create database and user on postgres
su - -c "psql -U postgres >/dev/null" postgres << 'EOF'
CREATE USER "php-crud-api" WITH PASSWORD 'php-crud-api';
CREATE DATABASE "php-crud-api";
GRANT ALL PRIVILEGES ON DATABASE "php-crud-api" to "php-crud-api";
\q
EOF
# run the tests
cd /root/php-crud-api
git pull
php phpunit.phar