Merge pull request #535 from zachborboa/docker

Add additional containers for unit tests
This commit is contained in:
Zach Borboa
2018-08-01 23:30:21 -07:00
committed by GitHub
19 changed files with 280 additions and 7 deletions
+24 -7
View File
@@ -27,13 +27,29 @@ php -r "var_dump(curl_version());"
composer self-update
composer install --prefer-source --no-interaction
# Use docker-specific settings.
if [ -f "/.dockerenv" ]; then
# Skip using sudo.
superuser=""
# Use unix socket.
fastcgi_pass="unix:/var/run/php5-fpm.sock"
else
# Use sudo.
superuser="sudo"
# Use ip socket.
fastcgi_pass="127.0.0.1:9000"
fi
if [[ "${TRAVIS_PHP_VERSION}" == "5.3" ]]; then
sudo add-apt-repository -y ppa:nginx/development
sudo apt-get update
sudo apt-get install -y nginx
sudo apt-get install -y php5-fpm
if ! [ -x "$(command -v add-apt-repository)" ]; then
$superuser apt-get install -y python-software-properties
fi
$superuser add-apt-repository -y ppa:nginx/development
$superuser apt-get update
$superuser apt-get install -y nginx
$superuser apt-get install -y php5-fpm
root="$(pwd)/tests/PHPCurlClass"
sudo tee /etc/nginx/sites-enabled/default <<EOF
$superuser tee /etc/nginx/sites-enabled/default <<EOF
server {
listen 8000 default_server;
root ${root};
@@ -44,14 +60,15 @@ server {
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_pass ${fastcgi_pass};
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
}
}
EOF
sudo /etc/init.d/nginx restart
$superuser /etc/init.d/php5-fpm start
$superuser /etc/init.d/nginx restart
phpunit_shim
elif [[ "${TRAVIS_PHP_VERSION}" == "5.4" ]]; then
php -S 127.0.0.1:8000 -t tests/PHPCurlClass/ &
+2
View File
@@ -0,0 +1,2 @@
# Build an image.
docker build --tag="php-curl-class/php53" .
+15
View File
@@ -0,0 +1,15 @@
# Run image to create container.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -x
cd "${SCRIPT_DIR}/../../.."
project_dir="${PWD}"
docker start "php53" ||
docker run \
--detach \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php53" \
--tty \
"php-curl-class/php53"
+17
View File
@@ -0,0 +1,17 @@
# Run tests inside container.
command=$(cat <<-END
mkdir --parents "/tmp/php-curl-class" &&
rsync --exclude=".git" --exclude="vendor" --links --recursive "/data/" "/tmp/php-curl-class/" &&
cd "/tmp/php-curl-class" &&
export TRAVIS_PHP_VERSION="5.3" &&
(
[ ! -f "/tmp/.composer_updated" ] &&
composer --no-interaction update &&
touch "/tmp/.composer_updated" ||
exit 0
) &&
bash "tests/before_script.sh" &&
bash "tests/script.sh"
END
)
docker exec --interactive --tty "php53" sh -c "${command}"
+3
View File
@@ -0,0 +1,3 @@
# Stop container.
docker stop "php53"
+66
View File
@@ -0,0 +1,66 @@
FROM debian:jessie
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get --assume-yes --quiet update
RUN apt-get --assume-yes --quiet install \
curl \
rsync \
# "/bin/sh: 1: make: not found"
make \
# "make[1]: *** No rule to make target '../include/openssl/bio.h', needed by 'cryptlib.o'. Stop."
# "configure: error: xml2-config not found. Please check your libxml2 installation."
libxml2-dev \
# "make[1]: gcc: Command not found"
gcc \
# tar (child): xz: Cannot exec: No such file or directory
# tar (child): Error is not recoverable: exiting now
# tar: Child returned status 2
# tar: Error is not recoverable: exiting now
xz-utils \
# "configure: error: Cannot find libz"
libssl-dev \
# "configure: error: Please reinstall the libcurl distribution -
# easy.h should be in <curl-dir>/include/curl/"
libcurl4-openssl-dev \
# "configure: error: png.h not found."
libpng-dev \
# "sh: 1: git: not found" (composer).
git \
# "Failed to download phpunit/phpunit from dist: The zip extension and unzip command are both missing,
# skipping."
zip
# Compile openssl so that php configure --with-openssl works.
RUN mkdir --parents "/tmp/openssl/" && \
curl --silent --show-error --output "openssl.tar.gz" \
"https://www.openssl.org/source/openssl-1.0.2k.tar.gz" && \
tar --extract --file "openssl.tar.gz" --directory "/tmp/openssl/" --strip-components="1" && \
cd "/tmp/openssl/" && \
./config && \
make && \
make install && \
rm -rf "/tmp/openssl/"
RUN mkdir --parents "/usr/src/php/" && \
curl --silent --show-error --output "php.tar.xz" \
"https://secure.php.net/distributions/php-5.3.29.tar.xz" && \
tar --extract --file "php.tar.xz" --directory "/usr/src/php/" --strip-components="1" && \
rm "php.tar.xz"* && \
cd "/usr/src/php/" && \
./configure \
--enable-mbstring \
--with-curl \
--with-gd \
--with-openssl="/usr/local/ssl" \
--with-zlib && \
make --jobs="$(nproc)" && \
make install && \
make clean
RUN curl --silent --show-error "https://getcomposer.org/installer" | php && \
mv "composer.phar" "/usr/local/bin/composer" && \
composer global require --no-interaction "phpunit/phpunit"
ENV PATH /root/.composer/vendor/bin:$PATH
CMD ["bash"]
+14
View File
@@ -0,0 +1,14 @@
# Run image to create container and attach to it.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -x
cd "${SCRIPT_DIR}/../../.."
project_dir="${PWD}"
docker run \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php53" \
--rm \
--tty \
"php-curl-class/php53" /bin/bash
+2
View File
@@ -0,0 +1,2 @@
# Build an image.
docker build --tag="php-curl-class/php54" .
+15
View File
@@ -0,0 +1,15 @@
# Run image to create container.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -x
cd "${SCRIPT_DIR}/../../.."
project_dir="${PWD}"
docker start "php54" ||
docker run \
--detach \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php54" \
--tty \
"php-curl-class/php54"
+17
View File
@@ -0,0 +1,17 @@
# Run tests inside container.
command=$(cat <<-END
mkdir --parents "/tmp/php-curl-class" &&
rsync --exclude=".git" --exclude="vendor" --links --recursive "/data/" "/tmp/php-curl-class/" &&
cd "/tmp/php-curl-class" &&
export TRAVIS_PHP_VERSION="5.4" &&
(
[ ! -f "/tmp/.composer_updated" ] &&
composer --no-interaction update &&
touch "/tmp/.composer_updated" ||
exit 0
) &&
bash "tests/before_script.sh" &&
bash "tests/script.sh"
END
)
docker exec --interactive --tty "php54" sh -c "${command}"
+3
View File
@@ -0,0 +1,3 @@
# Stop container.
docker stop "php54"
+19
View File
@@ -0,0 +1,19 @@
FROM php:5.4-cli
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get --assume-yes --quiet update
RUN apt-get --assume-yes --quiet install git && \
apt-get --assume-yes --quiet install libpng-dev && \
apt-get --assume-yes --quiet install zip
RUN curl --silent --show-error "https://getcomposer.org/installer" | php && \
mv "composer.phar" "/usr/local/bin/composer" && \
composer global require --no-interaction "phpunit/phpunit"
RUN docker-php-ext-configure gd && \
docker-php-ext-install gd && \
docker-php-ext-install mbstring
ENV PATH /root/.composer/vendor/bin:$PATH
CMD ["bash"]
+14
View File
@@ -0,0 +1,14 @@
# Run image to create container and attach to it.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -x
cd "${SCRIPT_DIR}/../../.."
project_dir="${PWD}"
docker run \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php54" \
--rm \
--tty \
"php-curl-class/php54" /bin/bash
+2
View File
@@ -0,0 +1,2 @@
# Build an image.
docker build --tag="php-curl-class/php55" .
+15
View File
@@ -0,0 +1,15 @@
# Run image to create container.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -x
cd "${SCRIPT_DIR}/../../.."
project_dir="${PWD}"
docker start "php55" ||
docker run \
--detach \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php55" \
--tty \
"php-curl-class/php55"
+17
View File
@@ -0,0 +1,17 @@
# Run tests inside container.
command=$(cat <<-END
mkdir --parents "/tmp/php-curl-class" &&
rsync --exclude=".git" --exclude="vendor" --links --recursive "/data/" "/tmp/php-curl-class/" &&
cd "/tmp/php-curl-class" &&
export TRAVIS_PHP_VERSION="5.5" &&
(
[ ! -f "/tmp/.composer_updated" ] &&
composer --no-interaction update &&
touch "/tmp/.composer_updated" ||
exit 0
) &&
bash "tests/before_script.sh" &&
bash "tests/script.sh"
END
)
docker exec --interactive --tty "php55" sh -c "${command}"
+3
View File
@@ -0,0 +1,3 @@
# Stop container.
docker stop "php55"
+18
View File
@@ -0,0 +1,18 @@
FROM php:5.5-cli
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get --assume-yes --quiet update
RUN apt-get --assume-yes --quiet install git && \
apt-get --assume-yes --quiet install libpng-dev && \
apt-get --assume-yes --quiet install zip
RUN curl --silent --show-error "https://getcomposer.org/installer" | php && \
mv "composer.phar" "/usr/local/bin/composer" && \
composer global require --no-interaction "phpunit/phpunit"
RUN docker-php-ext-configure gd && \
docker-php-ext-install gd
ENV PATH /root/.composer/vendor/bin:$PATH
CMD ["bash"]
+14
View File
@@ -0,0 +1,14 @@
# Run image to create container and attach to it.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -x
cd "${SCRIPT_DIR}/../../.."
project_dir="${PWD}"
docker run \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php55" \
--rm \
--tty \
"php-curl-class/php55" /bin/bash