diff --git a/php/test/README.md b/php/test/README.md index d75710f99ecc2e2ed2dd41a240bf1fa6890f0519..ddad51eb5208445d339109ea3bf7bb83f1472f13 100644 --- a/php/test/README.md +++ b/php/test/README.md @@ -1,65 +1,42 @@ -###Tests for the 7.2, 7.1 and 5.6 php/apache images +###Tests for the php/apache images -####php7.2 image : +####for php-apache images : ```shell -$ docker-compose -f docker-compose.test.7.2.yml up -Creating web.test.canals.php.7.2 -Attaching to web.test.canals.php.7.2 +$ ./docker-php-apache.test.sh tag ... ``` -should lead to the creation and enaction of a container named _web.test.canals.php.7.2_ . +should lead to the creation and enaction of a docker container based on image canals/php:tag. +Default value for tag is `latest` To verify that everything goes well, just point your preferred browser to the following urls: -+ http://localhost:27080/ -+ http://localhost:27080/index.html -+ http://localhost:27080/info.php -+ https://localhost:27443/ -+ https://localhost:27443/index.html -+ https://localhost:27443/info.php ++ http://localhost:9080/ ++ http://localhost:9080/index.html ++ http://localhost:9080/info.php ++ https://localhost:9443/ ++ https://localhost:9443/index.html ++ https://localhost:9443/info.php -####php7.1 image : +####for php-cli images : ```shell -$ docker-compose -f docker-compose.test.7.1.yml up -Creating web.test.canals.php.7.1 -Attaching to web.test.canals.php.7.1 +$ ./docker-php-cli.test.sh tag ... - ``` -should lead to the creation and enaction of a container named _web.test.canals.php.7.1_ . +should lead to the creation and enaction of a docker container based on the image canals/php:tag +The container runs the following command : +```shell +php -S 0.0.0.0:8000 +``` To verify that everything goes well, just point your preferred browser to the following urls: -+ http://localhost:25080/ -+ http://localhost:25080/index.html -+ http://localhost:25080/info.php -+ https://localhost:25443/ -+ https://localhost:25443/index.html -+ https://localhost:25443/info.php ++ http://localhost:8000/ ++ http://localhost:8000/fofo -####php5.6 image : - -```shell -$ docker-compose -f docker-compose.test.5.6.yml up - Creating web.test.canals.php.5.6 - Attaching to web.test.canals.php.5.6 -... - -``` - -should lead to the creation and enaction of a container named _web.test.canals.php.5.6_ . - -To verify that everything goes well, just point your preferred browser to the following urls: -* http://localhost:26080/ -* http://localhost:26080/index.html -* http://localhost:26080/info.php -* https://localhost:26443/ -* https://localhost:26443/index.html -* https://localhost:26443/info.php \ No newline at end of file diff --git a/php/test/docker-compose.test.5.6.yml b/php/test/docker-compose.test.5.6.yml deleted file mode 100644 index 9185882db8155e7f025a577d87f467a526f8773f..0000000000000000000000000000000000000000 --- a/php/test/docker-compose.test.5.6.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "3" -services: - web: - image: canals/php:5.6 - container_name: web.test.canals.php.5.6 - ports: - - "26080:80" - - "26443:443" - volumes : - - ./web:/var/www/html - - ./src:/var/www/src - - diff --git a/php/test/docker-compose.test.7.1.yml b/php/test/docker-compose.test.7.1.yml deleted file mode 100644 index 0dc9ecbdbccc5c56a8c956b3307c6955e0aa62e2..0000000000000000000000000000000000000000 --- a/php/test/docker-compose.test.7.1.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "3" -services: - web: - image: canals/php:7.1 - container_name: web.test.canals.php.7.1 - ports: - - "25080:80" - - "25443:443" - volumes : - - ./web:/var/www/html - - ./src:/var/www/src - - diff --git a/php/test/docker-compose.test.7.2.yml b/php/test/docker-compose.test.7.2.yml deleted file mode 100644 index 06ec0327108ec11c8060308e4cf8141e9c330492..0000000000000000000000000000000000000000 --- a/php/test/docker-compose.test.7.2.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "3" -services: - web: - image: canals/php:7.2 - container_name: web.test.canals.php.7.2 - ports: - - "27080:80" - - "27443:443" - volumes : - - ./web:/var/www/html - - ./src:/var/www/src - - diff --git a/php/test/docker-compose.test.7.3-cli.yml b/php/test/docker-compose.test.7.3-cli.yml deleted file mode 100644 index eba5d8557b3031ecab82160a3b7dff099adb8bc3..0000000000000000000000000000000000000000 --- a/php/test/docker-compose.test.7.3-cli.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: "3" -services: - php: - image: canals/php:7.3-cli - ports: - - "8800:8000" - volumes: - - ./src:/var/php - working_dir: /var/php - command: php -S 0.0.0.0:8000 index.php diff --git a/php/test/docker-compose.test.7.3.yml b/php/test/docker-compose.test.7.3.yml deleted file mode 100644 index ab98963c5e6f2e1a6c6fb9fb6e644a03b3a451b0..0000000000000000000000000000000000000000 --- a/php/test/docker-compose.test.7.3.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: "3" -services: - web: - image: canals/php:7.3 - container_name: web.test.canals.php.7.3 - ports: - - "27080:80" - - "27443:443" - volumes : - - ./web:/var/www/html - - ./src:/var/www/src - - diff --git a/php/test/docker-php-apache.test.sh b/php/test/docker-php-apache.test.sh new file mode 100755 index 0000000000000000000000000000000000000000..721b1be33d59fde1715bed64adb4e132c44ca93f --- /dev/null +++ b/php/test/docker-php-apache.test.sh @@ -0,0 +1,14 @@ +#!/usr/local/bin/bash + +tag="latest" +if [ $# -ge 1 ]; then + tag=$1 +fi + +echo "running a canals/php based container with tag : $tag" + +docker run --rm\ + -p 9080:80 -p 9443:443 \ + -v "$PWD"/html:/var/www/html \ + -v "$PWD"/src:/var/www/src \ + canals/php:$tag diff --git a/php/test/docker-php-cli.test.sh b/php/test/docker-php-cli.test.sh new file mode 100755 index 0000000000000000000000000000000000000000..b9607ed2ad6601fc6d1b60fdb50d539bda2649e1 --- /dev/null +++ b/php/test/docker-php-cli.test.sh @@ -0,0 +1,16 @@ +#!/usr/local/bin/bash + + +if [ $# -lt 1 ]; then + echo "no tag present, stopping" + exit 1 +fi + + + +docker run --rm -it \ + -p 8000:8000 \ + -v "$PWD"/src:/var/php \ + -w /var/php \ + canals/php:"$1" \ + php -S 0.0.0.0:8000 diff --git a/php/test/web/index.html b/php/test/html/index.html similarity index 100% rename from php/test/web/index.html rename to php/test/html/index.html diff --git a/php/test/web/index.php b/php/test/html/index.php similarity index 79% rename from php/test/web/index.php rename to php/test/html/index.php index 365327029127f02c9bb0d52a7c03040930a758bc..6dc7b552f53ebbc5f12be6acb26e166ccdcc5eb3 100644 --- a/php/test/web/index.php +++ b/php/test/html/index.php @@ -7,7 +7,7 @@ * @author: canals */ -require_once __DIR__ . '/../src/sample.php'; +$sample = require_once __DIR__ . '/../src/sample.php'; echo <<<EOT <!-- DOCTYPE html--> diff --git a/php/test/web/info.php b/php/test/html/info.php similarity index 100% rename from php/test/web/info.php rename to php/test/html/info.php diff --git a/php/test/src/index.php b/php/test/src/index.php index d43d8c564b059e0bf6fe29d302fba91ff06250ba..da498af4ebb300c0abd27ee1ce9a2a636928383b 100644 --- a/php/test/src/index.php +++ b/php/test/src/index.php @@ -8,4 +8,4 @@ echo "php is running !". '<br>'; -echo "uri : ". $_SERVER['PATH_INFO'] ; +echo "uri : ". ( isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : "/") ; diff --git a/php/test/src/sample.php b/php/test/src/sample.php index 9eec48d46496dab6e58629d91b2d181cb15cb937..e344314467429091713699fe438b0c31ad98ebdf 100644 --- a/php/test/src/sample.php +++ b/php/test/src/sample.php @@ -7,4 +7,6 @@ * @author: canals */ -$sample ='hungry heart'; \ No newline at end of file +$sample ='hungry heart'; + +return $sample; \ No newline at end of file