Skip to content

Commit 8a7e81e

Browse files
committed
add debian 8
1 parent 608dc3e commit 8a7e81e

File tree

8 files changed

+164
-0
lines changed

8 files changed

+164
-0
lines changed

docker/debian8-mariadb/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM debian:8
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

docker/debian8-mariadb/install.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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

docker/debian8-mariadb/packages.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
php5-cli \
10+
mariadb-server mariadb-client php5-mysql \
11+
postgresql php5-pgsql \
12+
sqlite php5-sqlite \
13+
git wget

docker/debian8-mariadb/run.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.4/bin/postgres -D /etc/postgresql/9.4/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

docker/debian8/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM debian:8
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

docker/debian8/install.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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

docker/debian8/packages.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
php5-cli \
10+
mysql-server mysql-client php5-mysql \
11+
postgresql php5-pgsql \
12+
sqlite php5-sqlite \
13+
git wget

docker/debian8/run.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# run mysql server
4+
nohup mysqld > /root/mysql.log 2>&1 &
5+
# wait for mysql to become available
6+
while ! mysqladmin ping -hlocalhost >/dev/null 2>&1; do
7+
sleep 1
8+
done
9+
# create database and user on mysql
10+
mysql -u root >/dev/null << 'EOF'
11+
CREATE DATABASE `php-crud-api` CHARACTER SET utf8 COLLATE utf8_general_ci;
12+
CREATE USER 'php-crud-api'@'localhost' IDENTIFIED BY 'php-crud-api';
13+
GRANT ALL PRIVILEGES ON `php-crud-api`.* TO 'php-crud-api'@'localhost' WITH GRANT OPTION;
14+
FLUSH PRIVILEGES;
15+
EOF
16+
17+
# run postgres server
18+
nohup su - -c "/usr/lib/postgresql/9.4/bin/postgres -D /etc/postgresql/9.4/main" postgres > /root/postgres.log 2>&1 &
19+
# wait for postgres to become available
20+
until su - -c "psql -U postgres -c '\q'" postgres >/dev/null 2>&1; do
21+
sleep 1;
22+
done
23+
# create database and user on postgres
24+
su - -c "psql -U postgres >/dev/null" postgres << 'EOF'
25+
CREATE USER "php-crud-api" WITH PASSWORD 'php-crud-api';
26+
CREATE DATABASE "php-crud-api";
27+
GRANT ALL PRIVILEGES ON DATABASE "php-crud-api" to "php-crud-api";
28+
\q
29+
EOF
30+
31+
# run the tests
32+
cd /root/php-crud-api
33+
git pull
34+
php phpunit.phar

0 commit comments

Comments
 (0)