Browse Source

Add Ubuntu 20.04 for Docker tests

Maurits van der Schee 4 years ago
parent
commit
1bfc8feebe
3 changed files with 92 additions and 0 deletions
  1. 12
    0
      README.md
  2. 20
    0
      docker/ubuntu20/Dockerfile
  3. 60
    0
      docker/ubuntu20/run.sh

+ 12
- 0
README.md View File

@@ -1158,6 +1158,17 @@ To run the docker tests run "build_all.sh" and "run_all.sh" from the docker dire
1158 1158
     mysql: 100 tests ran in 4327 ms, 0 failed
1159 1159
     pgsql: 100 tests ran in 1396 ms, 0 failed
1160 1160
     sqlsrv: skipped, driver not loaded
1161
+    ================================================
1162
+    Ubuntu 20.04 (PHP 7.3)
1163
+    ================================================
1164
+    [1/4] Starting MySQL 8.0 ........ done
1165
+    [2/4] Starting PostgreSQL 12 .... done
1166
+    [3/4] Starting SQLServer 2017 ... skipped
1167
+    [4/4] Cloning PHP-CRUD-API v2 ... skipped
1168
+    ------------------------------------------------
1169
+    mysql: 100 tests ran in 4327 ms, 0 failed
1170
+    pgsql: 100 tests ran in 1396 ms, 0 failed
1171
+    sqlsrv: skipped, driver not loaded
1161 1172
 
1162 1173
 The above test run (including starting up the databases) takes less than 5 minutes on my slow laptop.
1163 1174
 
@@ -1166,6 +1177,7 @@ The above test run (including starting up the databases) takes less than 5 minut
1166 1177
     2) debian9
1167 1178
     3) ubuntu16
1168 1179
     4) ubuntu18
1180
+    5) ubuntu20
1169 1181
     > 4
1170 1182
     ================================================
1171 1183
     Ubuntu 18.04 (PHP 7.2)

+ 20
- 0
docker/ubuntu20/Dockerfile View File

@@ -0,0 +1,20 @@
1
+FROM ubuntu:20.04
2
+
3
+ARG DEBIAN_FRONTEND=noninteractive
4
+
5
+# install: php / mysql / postgres / tools
6
+RUN apt-get update && apt-get -y install \
7
+php-cli php-xml \
8
+mysql-server mysql-client php-mysql \
9
+postgresql php-pgsql \
10
+postgresql-12-postgis-3 \
11
+git wget
12
+
13
+# install locales
14
+RUN apt-get -y install locales
15
+RUN locale-gen en_US.UTF-8
16
+RUN update-locale LANG=en_US.UTF-8
17
+
18
+# install run script
19
+ADD run.sh /usr/sbin/docker-run
20
+CMD docker-run

+ 60
- 0
docker/ubuntu20/run.sh View File

@@ -0,0 +1,60 @@
1
+#!/bin/bash
2
+echo "================================================"
3
+echo " Ubuntu 20.04 (PHP 7.3)"
4
+echo "================================================"
5
+
6
+echo -n "[1/4] Starting MySQL 8.0 ........ "
7
+# make sure mysql can create socket and lock
8
+mkdir /var/run/mysqld && chmod 777 /var/run/mysqld
9
+# run mysql server
10
+nohup mysqld > /root/mysql.log 2>&1 &
11
+# wait for mysql to become available
12
+while ! mysqladmin ping -hlocalhost >/dev/null 2>&1; do
13
+    sleep 1
14
+done
15
+# create database and user on mysql
16
+mysql -u root >/dev/null << 'EOF'
17
+CREATE DATABASE `php-crud-api` CHARACTER SET utf8 COLLATE utf8_general_ci;
18
+CREATE USER 'php-crud-api'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY 'php-crud-api';
19
+GRANT ALL PRIVILEGES ON `php-crud-api`.* TO 'php-crud-api'@'localhost' WITH GRANT OPTION;
20
+FLUSH PRIVILEGES;
21
+EOF
22
+echo "done"
23
+
24
+echo -n "[2/4] Starting PostgreSQL 12 .... "
25
+# ensure statistics can be written
26
+mkdir /var/run/postgresql/10-main.pg_stat_tmp/ && chmod 777 /var/run/postgresql/10-main.pg_stat_tmp/
27
+# run postgres server
28
+nohup su - -c "/usr/lib/postgresql/12/bin/postgres -D /etc/postgresql/12/main" postgres > /root/postgres.log 2>&1 &
29
+# wait for postgres to become available
30
+until su - -c "psql -U postgres -c '\q'" postgres >/dev/null 2>&1; do
31
+   sleep 1;
32
+done
33
+# create database and user on postgres
34
+su - -c "psql -U postgres >/dev/null" postgres << 'EOF'
35
+CREATE USER "php-crud-api" WITH PASSWORD 'php-crud-api';
36
+CREATE DATABASE "php-crud-api";
37
+GRANT ALL PRIVILEGES ON DATABASE "php-crud-api" to "php-crud-api";
38
+\c "php-crud-api";
39
+CREATE EXTENSION IF NOT EXISTS postgis;
40
+\q
41
+EOF
42
+echo "done"
43
+
44
+echo -n "[3/4] Starting SQLServer 2017 ... "
45
+echo "skipped"
46
+
47
+echo -n "[4/4] Cloning PHP-CRUD-API v2 ... "
48
+# install software
49
+if [ -d /php-crud-api ]; then
50
+  echo "skipped"
51
+else
52
+  git clone --quiet https://github.com/mevdschee/php-crud-api.git
53
+  echo "done"
54
+fi
55
+
56
+echo "------------------------------------------------"
57
+
58
+# run the tests
59
+cd php-crud-api
60
+php test.php

Loading…
Cancel
Save