Browse Source

Add ubuntu docker images for tests

Maurits van der Schee 6 years ago
parent
commit
37c360f27f

+ 10
- 0
docker/ubuntu12/Dockerfile View File

@@ -0,0 +1,10 @@
1
+FROM ubuntu:12.04
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
+ENTRYPOINT docker-run; sleep infinity

+ 24
- 0
docker/ubuntu12/install.sh View File

@@ -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

+ 13
- 0
docker/ubuntu12/packages.sh View File

@@ -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

+ 34
- 0
docker/ubuntu12/run.sh View File

@@ -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.1/bin/postgres -D /etc/postgresql/9.1/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

+ 10
- 0
docker/ubuntu14/Dockerfile View File

@@ -0,0 +1,10 @@
1
+FROM ubuntu:14.04
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
+ENTRYPOINT docker-run; sleep infinity

+ 24
- 0
docker/ubuntu14/install.sh View File

@@ -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

+ 13
- 0
docker/ubuntu14/packages.sh View File

@@ -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

+ 34
- 0
docker/ubuntu14/run.sh View File

@@ -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.3/bin/postgres -D /etc/postgresql/9.3/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

+ 10
- 0
docker/ubuntu16-mariadb/Dockerfile View File

@@ -0,0 +1,10 @@
1
+FROM ubuntu:16.04
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
+ENTRYPOINT docker-run; sleep infinity

+ 24
- 0
docker/ubuntu16-mariadb/install.sh View File

@@ -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

+ 13
- 0
docker/ubuntu16-mariadb/packages.sh View File

@@ -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
+php-cli php-xml \
10
+mariadb-server mariadb-client php-mysql \
11
+postgresql php-pgsql \
12
+sqlite php-sqlite3 \
13
+git wget

+ 36
- 0
docker/ubuntu16-mariadb/run.sh View File

@@ -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_safe > /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.5/bin/postgres -D /etc/postgresql/9.5/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

+ 10
- 0
docker/ubuntu16/Dockerfile View File

@@ -0,0 +1,10 @@
1
+FROM ubuntu:16.04
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
+ENTRYPOINT docker-run; sleep infinity

+ 24
- 0
docker/ubuntu16/install.sh View File

@@ -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

+ 13
- 0
docker/ubuntu16/packages.sh View File

@@ -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
+php-cli php-xml \
10
+mysql-server mysql-client php-mysql \
11
+postgresql php-pgsql \
12
+sqlite php-sqlite3 \
13
+git wget

+ 36
- 0
docker/ubuntu16/run.sh View File

@@ -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_safe > /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.5/bin/postgres -D /etc/postgresql/9.5/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

Loading…
Cancel
Save