Browse Source

Added centos7 to docker

Maurits van der Schee 7 years ago
parent
commit
47c09cdd6f
4 changed files with 82 additions and 0 deletions
  1. 10
    0
      docker/centos7/Dockerfile
  2. 24
    0
      docker/centos7/install.sh
  3. 11
    0
      docker/centos7/packages.sh
  4. 37
    0
      docker/centos7/run.sh

+ 10
- 0
docker/centos7/Dockerfile View File

@@ -0,0 +1,10 @@
1
+FROM centos:7
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

+ 24
- 0
docker/centos7/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

+ 11
- 0
docker/centos7/packages.sh View File

@@ -0,0 +1,11 @@
1
+#!/bin/bash
2
+
3
+# update should not be needed
4
+# yum -y upgdate
5
+# install: php / mysql / postgres / sqlite / tools
6
+yum -y install \
7
+php-cli php-xml \
8
+mariadb-server mariadb php-mysql \
9
+postgresql-server postgresql php-pgsql \
10
+sqlite php-sqlite3 \
11
+git wget

+ 37
- 0
docker/centos7/run.sh View File

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

Loading…
Cancel
Save