From 9e01945bde368609205c03f0916c19efc3c0c181 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Mon, 16 Mar 2020 20:46:57 -0400 Subject: [PATCH] Dockerize - Deleted unused file .coveralls.yml - Reworked dockerfile, updated README.md - Added docker-compose.yml file bases on PHP 7.2 - Install composer in /usr/bin/composer (usr/local/bin/composer is more proper, but doesn't work) - change Makefile to be more as expected - composer lock update --- .coveralls.yml | 2 -- Dockerfile | 22 ++++++++++++++++++++++ Makefile | 16 ++++++++++++++++ README.md | 11 +++++++++++ composer-install.sh | 17 +++++++++++++++++ composer.lock | 3 +-- docker-compose.yml | 17 +++++++++++++++++ 7 files changed, 84 insertions(+), 4 deletions(-) delete mode 100644 .coveralls.yml create mode 100644 Dockerfile create mode 100755 composer-install.sh create mode 100644 docker-compose.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index fb796f6..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1,2 +0,0 @@ -service_name: travis-ci -src_dir: SilMock diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d1facea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM silintl/php7:7.2 +MAINTAINER Mark Tompsett + +ENV REFRESHED_AT 2020-03-16 + +# Fix timezone stuff from hanging. +RUN apt-get update -y && echo "America/New_York" > /etc/timezone; \ + apt-get install -y tzdata + +# Make sure apt has current list/updates +# Install necessary PHP building blocks +# Install Apache and PHP (and any needed extensions). +# Install mock DB stuff +RUN apt-get install -y zip unzip make curl wget \ + php php-pdo php-xml php-mbstring sqlite php-sqlite3 + +RUN mkdir -p /data +WORKDIR /data +COPY ./ /data + +RUN cd /data && ./composer-install.sh +RUN mv /data/composer.phar /usr/bin/composer diff --git a/Makefile b/Makefile index 5543b93..1e35e14 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,18 @@ +it-now: clean install phpunit + +clean: + sudo rm -rf ./vendor + rm -f composer.lock + +install: + docker-compose run --rm cli bash -c "cd /data;composer install" + +update: + docker-compose run --rm cli bash -c "cd /data;composer update" + +phpunit: + docker-compose run --rm cli bash -c "cd /data/SilMock/tests;./phpunit" + +# For use in virtualbox. test: cd /var/lib/GA_mock/SilMock/tests; /var/lib/GA_mock/SilMock/tests/phpunit diff --git a/README.md b/README.md index b2519ac..9094009 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,17 @@ implements include... 1. listUsersSettingsForwardingAddresses() +Unit Testing +------------ +If you are able to run docker natively, then: + - make it-now + +If not, then use vagrant up: + - vagrant up + - vagrant ssh + - cd /var/lib/GA_mock + - make test + Data Persistence ---------------- In order to keep data available for use by this mock, it makes use of a **Sqlite** diff --git a/composer-install.sh b/composer-install.sh new file mode 100755 index 0000000..40250f5 --- /dev/null +++ b/composer-install.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)" +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" + +if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] +then + >&2 echo 'ERROR: Invalid installer checksum' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --quiet +RESULT=$? +rm composer-setup.php +exit $RESULT diff --git a/composer.lock b/composer.lock index 4cd6d86..d9c5f28 100644 --- a/composer.lock +++ b/composer.lock @@ -1615,6 +1615,5 @@ "ext-json": "*", "ext-mbstring": "*" }, - "platform-dev": [], - "plugin-api-version": "1.1.0" + "platform-dev": [] } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b743fc2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '2.2' +services: + cli: + build: ./ + volumes: + - ./:/data + working_dir: /data + command: ["true"] + +networks: + default: + driver: bridge + ipam: + driver: default + config: + - subnet: 10.20.35.0/24 + gateway: 10.20.35.1