From bc34e507eb07fc8d3eed61252c5b0aa4c2b2fafe Mon Sep 17 00:00:00 2001 From: mik-p Date: Sat, 2 Oct 2021 22:07:29 +1000 Subject: [PATCH] test composer 2, add some tests, update readme, update generated container files --- Dockerfile.develop.template | 3 +-- Dockerfile.template | 3 +-- README.md | 18 +++++++++++++++--- php7.2/apache/Dockerfile | 3 +-- php7.2/apache/Dockerfile.develop | 7 +++---- php7.2/fpm/Dockerfile | 3 +-- php7.2/fpm/Dockerfile.develop | 7 +++---- php7.3/apache/Dockerfile | 3 +-- php7.3/apache/Dockerfile.develop | 7 +++---- php7.3/fpm/Dockerfile | 3 +-- php7.3/fpm/Dockerfile.develop | 7 +++---- php7.4/apache/Dockerfile | 3 +-- php7.4/apache/Dockerfile.develop | 7 +++---- php7.4/fpm/Dockerfile | 3 +-- php7.4/fpm/Dockerfile.develop | 7 +++---- test/init_plugins.bash | 28 ++++++++++++++++++++++++++++ test/init_winter.bash | 30 ++++++++++++++++++++++++++++++ update.sh | 15 +++++++++++++++ version | 4 ++-- 19 files changed, 116 insertions(+), 45 deletions(-) create mode 100755 test/init_plugins.bash create mode 100755 test/init_winter.bash diff --git a/Dockerfile.develop.template b/Dockerfile.develop.template index 166c28d7..6a868055 100644 --- a/Dockerfile.develop.template +++ b/Dockerfile.develop.template @@ -36,8 +36,7 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer %%VARIANT_EXTRAS%% diff --git a/Dockerfile.template b/Dockerfile.template index 44118ab2..124c54b9 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -27,8 +27,7 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer %%VARIANT_EXTRAS%% diff --git a/README.md b/README.md index 55e0e4f4..114f4ffc 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Based on [official docker PHP images](https://hub.docker.com/_/php), images incl - `develop-php7.2-apache`, `develop`: [php7.2/apache/Dockerfile.develop](https://github.com/mik-p/docker-wintercms/blob/master/php7.2/apache/Dockerfile.develop) - `develop-php7.2-fpm`: [php7.2/fpm/Dockerfile.develop](https://github.com/mik-p/docker-wintercms/blob/master/php7.2/fpm/Dockerfile.develop) +--- + ## Quick Start To run Winter CMS using Docker, start a container using the latest image, mapping your local port 80 to the container's port 80: @@ -52,6 +54,7 @@ $ docker rm winter # Destroys the container - Hit `CTRL-C` to stop the container. Running a container in the foreground will send log outputs to your terminal. - Run the container in the background by passing the `-d` option: +
## Working with Local Files @@ -88,6 +91,7 @@ $ docker-compose up -d # start services defined in `docker-compose.yml` in the b $ docker-compose down # stop and destroy ``` +
## Database Support @@ -145,6 +149,8 @@ $ docker-compose up -d $ docker-compose exec web php artisan winter:up ``` +
+ ## Cron You can start a cron process by setting the environment variable `ENABLE_CRON` to `true`: @@ -186,6 +192,8 @@ services: - web ``` +
+ ## Self Signed Certificates Sometimes encyption is useful for testing. Self signed certs can be added by extending the image in another dockerfile: @@ -238,6 +246,8 @@ services: - MYSQL_ROOT_PASSWORD=root ``` +
+ ## Command Line Tasks Run the container in the background and launch an interactive shell (bash) for the container: @@ -271,6 +281,7 @@ $ docker exec containername artisan plugin:install winter.user $ docker exec -it containername tinker ``` +
## App Environment @@ -280,7 +291,7 @@ On image build, a default `.env` is created and [config files](./config/docker) > __Note__: Winter CMS settings stored in a site's database override the config. Active theme, mail configuration, and other settings which are saved in the database will ultimately override configuration values. -#### PHP configuration +### PHP configuration Recommended settings for opcache and PHP are applied on image build. @@ -297,8 +308,9 @@ Environment variables can be passed to both docker-compose and Winter CMS. > Passing environment variables via Docker can be problematic in production. A `phpinfo()` call may leak secrets by outputting environment variables. Consider mounting a `.env` volume or copying it to the container directly. +
-#### Docker Entrypoint +### Docker Entrypoint The following variables trigger actions run by the [entrypoint script](./docker-wn-entrypoint) at runtime. @@ -320,7 +332,7 @@ The following variables trigger actions run by the [entrypoint script](./docker- | XDEBUG_ENABLE | false | `true` enables the Xdebug PHP extension | | XDEBUG_REMOTE_HOST | host.docker.internal | Override value for `xdebug.remote_host` in docker-xdebug-php.ini | -#### Winter CMS app environment config +### Winter CMS app environment config List of variables used in `config/docker` diff --git a/php7.2/apache/Dockerfile b/php7.2/apache/Dockerfile index 5d88bd63..76b8e531 100644 --- a/php7.2/apache/Dockerfile +++ b/php7.2/apache/Dockerfile @@ -26,8 +26,7 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer RUN a2enmod rewrite diff --git a/php7.2/apache/Dockerfile.develop b/php7.2/apache/Dockerfile.develop index 085448b1..e050eafe 100644 --- a/php7.2/apache/Dockerfile.develop +++ b/php7.2/apache/Dockerfile.develop @@ -35,16 +35,15 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer RUN a2enmod rewrite COPY config/docker /usr/src/wintercms-config-docker ENV WINTERCMS_TAG develop -ENV WINTERCMS_DEVELOP_CHECKSUM 01b4c7d88a039e988cb650212fb9570eadb382c7 -ENV WINTERCMS_DEVELOP_COMMIT affdcce339e0b0cece1952fac08af9ee74d2255c +ENV WINTERCMS_DEVELOP_CHECKSUM e6cad3d6a87a18f0ca80578c501546b3ec9cbb87 +ENV WINTERCMS_DEVELOP_COMMIT 7aea162fe2f383e800c29f8130c67c182e7573bd RUN git clone https://github.com/wintercms/winter.git -b $WINTERCMS_TAG . && \ composer install --no-interaction --prefer-dist --no-scripts && \ diff --git a/php7.2/fpm/Dockerfile b/php7.2/fpm/Dockerfile index 6dfa0a3b..26581b67 100644 --- a/php7.2/fpm/Dockerfile +++ b/php7.2/fpm/Dockerfile @@ -26,8 +26,7 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer diff --git a/php7.2/fpm/Dockerfile.develop b/php7.2/fpm/Dockerfile.develop index 00b148c3..2a30d8d8 100644 --- a/php7.2/fpm/Dockerfile.develop +++ b/php7.2/fpm/Dockerfile.develop @@ -35,16 +35,15 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer COPY config/docker /usr/src/wintercms-config-docker ENV WINTERCMS_TAG develop -ENV WINTERCMS_DEVELOP_CHECKSUM 01b4c7d88a039e988cb650212fb9570eadb382c7 -ENV WINTERCMS_DEVELOP_COMMIT affdcce339e0b0cece1952fac08af9ee74d2255c +ENV WINTERCMS_DEVELOP_CHECKSUM e6cad3d6a87a18f0ca80578c501546b3ec9cbb87 +ENV WINTERCMS_DEVELOP_COMMIT 7aea162fe2f383e800c29f8130c67c182e7573bd RUN git clone https://github.com/wintercms/winter.git -b $WINTERCMS_TAG . && \ composer install --no-interaction --prefer-dist --no-scripts && \ diff --git a/php7.3/apache/Dockerfile b/php7.3/apache/Dockerfile index 936a1b7a..27aead68 100644 --- a/php7.3/apache/Dockerfile +++ b/php7.3/apache/Dockerfile @@ -26,8 +26,7 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer RUN a2enmod rewrite diff --git a/php7.3/apache/Dockerfile.develop b/php7.3/apache/Dockerfile.develop index 9ac9785b..defb7187 100644 --- a/php7.3/apache/Dockerfile.develop +++ b/php7.3/apache/Dockerfile.develop @@ -35,16 +35,15 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer RUN a2enmod rewrite COPY config/docker /usr/src/wintercms-config-docker ENV WINTERCMS_TAG develop -ENV WINTERCMS_DEVELOP_CHECKSUM 01b4c7d88a039e988cb650212fb9570eadb382c7 -ENV WINTERCMS_DEVELOP_COMMIT affdcce339e0b0cece1952fac08af9ee74d2255c +ENV WINTERCMS_DEVELOP_CHECKSUM e6cad3d6a87a18f0ca80578c501546b3ec9cbb87 +ENV WINTERCMS_DEVELOP_COMMIT 7aea162fe2f383e800c29f8130c67c182e7573bd RUN git clone https://github.com/wintercms/winter.git -b $WINTERCMS_TAG . && \ composer install --no-interaction --prefer-dist --no-scripts && \ diff --git a/php7.3/fpm/Dockerfile b/php7.3/fpm/Dockerfile index 4b617861..ee27e381 100644 --- a/php7.3/fpm/Dockerfile +++ b/php7.3/fpm/Dockerfile @@ -26,8 +26,7 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer diff --git a/php7.3/fpm/Dockerfile.develop b/php7.3/fpm/Dockerfile.develop index 8340a0c3..d5ca1a97 100644 --- a/php7.3/fpm/Dockerfile.develop +++ b/php7.3/fpm/Dockerfile.develop @@ -35,16 +35,15 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer COPY config/docker /usr/src/wintercms-config-docker ENV WINTERCMS_TAG develop -ENV WINTERCMS_DEVELOP_CHECKSUM 01b4c7d88a039e988cb650212fb9570eadb382c7 -ENV WINTERCMS_DEVELOP_COMMIT affdcce339e0b0cece1952fac08af9ee74d2255c +ENV WINTERCMS_DEVELOP_CHECKSUM e6cad3d6a87a18f0ca80578c501546b3ec9cbb87 +ENV WINTERCMS_DEVELOP_COMMIT 7aea162fe2f383e800c29f8130c67c182e7573bd RUN git clone https://github.com/wintercms/winter.git -b $WINTERCMS_TAG . && \ composer install --no-interaction --prefer-dist --no-scripts && \ diff --git a/php7.4/apache/Dockerfile b/php7.4/apache/Dockerfile index 2997b1a2..65db0362 100644 --- a/php7.4/apache/Dockerfile +++ b/php7.4/apache/Dockerfile @@ -26,8 +26,7 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer RUN a2enmod rewrite diff --git a/php7.4/apache/Dockerfile.develop b/php7.4/apache/Dockerfile.develop index 3f975d96..bae90169 100644 --- a/php7.4/apache/Dockerfile.develop +++ b/php7.4/apache/Dockerfile.develop @@ -35,16 +35,15 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer RUN a2enmod rewrite COPY config/docker /usr/src/wintercms-config-docker ENV WINTERCMS_TAG develop -ENV WINTERCMS_DEVELOP_CHECKSUM 01b4c7d88a039e988cb650212fb9570eadb382c7 -ENV WINTERCMS_DEVELOP_COMMIT affdcce339e0b0cece1952fac08af9ee74d2255c +ENV WINTERCMS_DEVELOP_CHECKSUM e6cad3d6a87a18f0ca80578c501546b3ec9cbb87 +ENV WINTERCMS_DEVELOP_COMMIT 7aea162fe2f383e800c29f8130c67c182e7573bd RUN git clone https://github.com/wintercms/winter.git -b $WINTERCMS_TAG . && \ composer install --no-interaction --prefer-dist --no-scripts && \ diff --git a/php7.4/fpm/Dockerfile b/php7.4/fpm/Dockerfile index edfc6164..de707cc2 100644 --- a/php7.4/fpm/Dockerfile +++ b/php7.4/fpm/Dockerfile @@ -26,8 +26,7 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer diff --git a/php7.4/fpm/Dockerfile.develop b/php7.4/fpm/Dockerfile.develop index 34482948..b0bccbcc 100644 --- a/php7.4/fpm/Dockerfile.develop +++ b/php7.4/fpm/Dockerfile.develop @@ -35,16 +35,15 @@ RUN { \ ENV COMPOSER_ALLOW_SUPERUSER=1 -RUN curl -sS https://getcomposer.org/installer | php -- --1 --install-dir=/usr/local/bin --filename=composer && \ - /usr/local/bin/composer global require hirak/prestissimo +RUN curl -sS https://getcomposer.org/installer | php -- --2 --install-dir=/usr/local/bin --filename=composer COPY config/docker /usr/src/wintercms-config-docker ENV WINTERCMS_TAG develop -ENV WINTERCMS_DEVELOP_CHECKSUM 01b4c7d88a039e988cb650212fb9570eadb382c7 -ENV WINTERCMS_DEVELOP_COMMIT affdcce339e0b0cece1952fac08af9ee74d2255c +ENV WINTERCMS_DEVELOP_CHECKSUM e6cad3d6a87a18f0ca80578c501546b3ec9cbb87 +ENV WINTERCMS_DEVELOP_COMMIT 7aea162fe2f383e800c29f8130c67c182e7573bd RUN git clone https://github.com/wintercms/winter.git -b $WINTERCMS_TAG . && \ composer install --no-interaction --prefer-dist --no-scripts && \ diff --git a/test/init_plugins.bash b/test/init_plugins.bash new file mode 100755 index 00000000..70dc53cd --- /dev/null +++ b/test/init_plugins.bash @@ -0,0 +1,28 @@ +#!/bin/bash -e + +TEST_ROOT=test +SOURCE_ROOT=.. + +if [ "$(basename $(pwd))" != "$TEST_ROOT" ]; then + echo "test run in wrong directory" + exit 1 +fi + +TEST_CONTAINER_NAME=test-wn-init-plugins +TEST_CONTAINER_TYPE=$SOURCE_ROOT/php7.4/apache + +echo "build test" +docker build -t $TEST_CONTAINER_NAME $TEST_CONTAINER_TYPE || exit 1 + +echo "run test container" +docker run \ + -it \ + --rm \ + -p 8888:80 \ + -e INIT_PLUGINS=true \ + $TEST_CONTAINER_NAME \ + bash -c "echo 'container test run complete'; exit 0" || exit 1 + +echo "test done" + +exit 0 diff --git a/test/init_winter.bash b/test/init_winter.bash new file mode 100755 index 00000000..18e27c92 --- /dev/null +++ b/test/init_winter.bash @@ -0,0 +1,30 @@ +#!/bin/bash -e + +TEST_ROOT=test +SOURCE_ROOT=.. + +if [ "$(basename $(pwd))" != "$TEST_ROOT" ]; then + echo "test run in wrong directory" + exit 1 +fi + +TEST_CONTAINER_NAME=test-wn-init-winter +TEST_CONTAINER_TYPE=$SOURCE_ROOT/php7.4/apache +TEST_CONTAINER_DOCKERFILE=Dockerfile +# TEST_CONTAINER_DOCKERFILE=Dockerfile.develop + +echo "build test" +docker build -t $TEST_CONTAINER_NAME $TEST_CONTAINER_TYPE || exit 1 + +echo "run test container" +docker run \ + -it \ + --rm \ + -p 8888:80 \ + -e INIT_WINTER=true \ + $TEST_CONTAINER_NAME \ + bash -c "echo 'container test run complete'; exit 0" || exit 1 + +echo "test done" + +exit 0 diff --git a/update.sh b/update.sh index 753a7950..8af9f1cf 100755 --- a/update.sh +++ b/update.sh @@ -231,6 +231,7 @@ while true; do --force) FORCE=1; shift ;; --push) PUSH=1; shift ;; --rewrite) REWRITE_ONLY=1; shift ;; + -h) HELP_MSG=1; shift ;; *) break esac @@ -240,6 +241,20 @@ done ### Run echo "Automat: `date`" +echo "" +echo "usage: ./update.sh [options]" +echo "" +echo "options:" +echo "-h this message" +echo "" +echo "--force force the process" +echo "--push push the changes to source repository" +echo "--rewrite only rewrite the local files" +echo "" + +[ "$HELP_MSG" ] && exit 0 + +echo "starting update:" [ "$PUSH" ] && echo ' - Commit changes' # Load cached version if not forced diff --git a/version b/version index 218dbd27..852bb0ac 100644 --- a/version +++ b/version @@ -1,4 +1,4 @@ WINTERCMS_BUILD=v1.0.474 WINTERCMS_CHECKSUM=5196ccd82d81c79667869056a2b7e27dc34a38a1 -WINTERCMS_DEVELOP_COMMIT=affdcce339e0b0cece1952fac08af9ee74d2255c -WINTERCMS_DEVELOP_CHECKSUM=01b4c7d88a039e988cb650212fb9570eadb382c7 +WINTERCMS_DEVELOP_COMMIT=7aea162fe2f383e800c29f8130c67c182e7573bd +WINTERCMS_DEVELOP_CHECKSUM=e6cad3d6a87a18f0ca80578c501546b3ec9cbb87