diff --git a/.dockerignore b/.dockerignore index 09e41b84..72d69bba 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,7 +5,6 @@ .git .idea -bin docker-output docs img diff --git a/bin/_lib.sh b/bin/_lib.sh index 6cd705c5..e6bf9289 100644 --- a/bin/_lib.sh +++ b/bin/_lib.sh @@ -96,35 +96,61 @@ configure_wordpress() { wp rewrite structure '/%year%/%monthnum%/%postname%/' --hard } -install_plugins() { - cd $WP_CORE_DIR +install_gf() { + if ! $(wp plugin is-installed gravityformscli --allow-root); then + wp plugin install gravityformscli --allow-root + fi + wp plugin activate gravityformscli --allow-root - wp plugin list --allow-root + echo "Installing and Activating Gravity Forms + extensions"; + if ! $(wp plugin is-installed gravityforms --allow-root); then + wp gf install --key=$GF_KEY --allow-root --quiet + fi + wp plugin activate gravityforms --allow-root + if ! $(wp plugin is-installed gravityformssignature --allow-root); then + wp gf install gravityformssignature --key=$GF_KEY --allow-root --quiet + fi + wp plugin activate gravityformssignature --allow-root + + if ! $(wp plugin is-installed gravityformschainedselects --allow-root); then + wp gf install gravityformschainedselects --key=$GF_KEY --allow-root --quiet + fi + wp plugin activate gravityformschainedselects --allow-root + + if ! $(wp plugin is-installed gravityformsquiz --allow-root); then + wp gf install gravityformsquiz --key=$GF_KEY --allow-root --quiet + fi + wp plugin activate gravityformsquiz --allow-root +} + +install_plugins() { # Install GF plugins and Activate. - wp plugin install gravityformscli --activate --allow-root + install_gf || true - echo "Installing and Activating Gravity Forms + extensions"; - wp gf install --key=$GF_KEY --activate --allow-root --quiet - wp gf install gravityformssignature --key=$GF_KEY --activate --allow-root --quiet - wp gf install gravityformschainedselects --key=$GF_KEY --activate --allow-root --quiet - wp gf install gravityformsquiz --key=$GF_KEY --activate --allow-root --quiet + # Install WPGraphQL and Activate + if ! $(wp plugin is-installed wp-graphql --allow-root); then + wp plugin install wp-graphql --allow-root + fi + wp plugin activate wp-graphql --allow-root # Install WPGraphQL Upload and Activate - wp plugin install https://github.com/dre1080/wp-graphql-upload/archive/refs/heads/master.zip --allow-root + if ! $(wp plugin is-installed wp-graphql-upload --allow-root); then + wp plugin install https://github.com/dre1080/wp-graphql-upload/archive/refs/heads/master.zip --allow-root + fi wp plugin activate wp-graphql-upload --allow-root - # Install WPGraphQL and Activate - wp plugin install wp-graphql --allow-root - wp plugin activate wp-graphql --allow-root # Install WPGatsby and Activate - wp plugin install wp-gatsby --allow-root + if ! $(wp plugin is-installed wp-gatsby --allow-root); then + wp plugin install wp-gatsby --allow-root + fi wp plugin activate wp-gatsby --allow-root # Install WPJamstack Deployments and Activate - wp plugin install wp-jamstack-deployments --allow-root - wp plugin activate wp-jamstack-deployments --allow-root + if ! $(wp plugin is-installed wp-jamstack-deployments --allow-root); then + wp plugin install wp-jamstack-deployments --allow-root + fi } setup_plugin() { diff --git a/bin/install-stan-env.sh b/bin/install-stan-env.sh index 3d2fed1c..10c27be8 100644 --- a/bin/install-stan-env.sh +++ b/bin/install-stan-env.sh @@ -15,5 +15,8 @@ source ${BASEDIR}/_lib.sh install_wordpress install_db configure_wordpress + +cd $WP_CORE_DIR install_plugins + post_setup diff --git a/bin/install-test-env.sh b/bin/install-test-env.sh index cb057053..a54f3147 100644 --- a/bin/install-test-env.sh +++ b/bin/install-test-env.sh @@ -15,6 +15,9 @@ source ${BASEDIR}/_lib.sh install_wordpress install_db configure_wordpress + +cd $WP_CORE_DIR install_plugins + setup_plugin post_setup diff --git a/docker-compose.yml b/docker-compose.yml index a9382746..dc219561 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: - app_db image: wp-graphql-gravity-forms:latest-wp${WP_VERSION-6.0}-php${PHP_VERSION-8.0} volumes: + - wpdata:/var/www/html - .:/var/www/html/wp-content/plugins/wp-graphql-gravity-forms - ./.log/app:/var/log/apache2 env_file: @@ -35,9 +36,11 @@ services: testing: depends_on: + - app - app_db image: wp-graphql-gravity-forms-testing:latest-wp${WP_VERSION-6.0}-php${PHP_VERSION-8.0} volumes: + - wpdata:/var/www/html - .:/var/www/html/wp-content/plugins/wp-graphql-gravity-forms - ./.log/testing:/var/log/apache2 env_file: @@ -52,3 +55,6 @@ services: networks: local: testing: + +volumes: + wpdata: diff --git a/docker/app.Dockerfile b/docker/app.Dockerfile index 86f6c285..c81b7a8c 100644 --- a/docker/app.Dockerfile +++ b/docker/app.Dockerfile @@ -78,6 +78,7 @@ ENV USING_XDEBUG=0 # Set up entrypoint WORKDIR /var/www/html +COPY bin/_lib.sh /usr/local/bin/_lib.sh COPY docker/app.setup.sh /usr/local/bin/app-setup.sh COPY docker/app.post-setup.sh /usr/local/bin/app-post-setup.sh COPY docker/app.entrypoint.sh /usr/local/bin/app-entrypoint.sh diff --git a/docker/app.post-setup.sh b/docker/app.post-setup.sh index e09df551..f8ba1301 100644 --- a/docker/app.post-setup.sh +++ b/docker/app.post-setup.sh @@ -1,49 +1,11 @@ #!/bin/bash - -install_gf() { - # Install GF plugins and Activate. - wp plugin install gravityformscli --activate --allow-root - - echo "Installing and Activating Gravity Forms + extensions"; - wp gf install --key=$GF_KEY --allow-root --quiet - wp plugin activate gravityforms --allow-root - - wp gf install gravityformssignature --key=$GF_KEY --allow-root --quiet - wp plugin activate gravityformssignature --allow-root - - wp gf install gravityformschainedselects --key=$GF_KEY --allow-root --quiet - wp plugin activate gravityformschainedselects --allow-root - - wp gf install gravityformsquiz --key=$GF_KEY --allow-root --quiet - wp plugin activate gravityformsquiz --allow-root -} - -# Install plugins -install_gf || true - - -# Install WPGraphQL Upload and Activate -wp plugin install https://github.com/dre1080/wp-graphql-upload/archive/refs/heads/master.zip --allow-root -wp plugin activate wp-graphql-upload --allow-root - -# Install WPGraphQL and Activate -wp plugin install wp-graphql --allow-root -wp plugin activate wp-graphql --allow-root - -# Install WPGatsby and Activate -wp plugin install wp-gatsby --allow-root -wp plugin activate wp-gatsby --allow-root - -# Install WPJamstack Deployments and Activate -wp plugin install wp-jamstack-deployments --allow-root -wp plugin activate wp-jamstack-deployments --allow-root - # activate the plugin wp plugin activate wp-graphql-gravity-forms --allow-root # Set pretty permalinks. wp rewrite structure '/%year%/%monthnum%/%postname%/' --allow-root +wp rewrite flush --allow-root # Export the db for codeception to use wp db export "${DATA_DUMP_DIR}/dump.sql" --allow-root @@ -54,6 +16,5 @@ if $(wp maintenance-mode is-active --allow-root); then wp maintenance-mode deactivate --allow-root fi - chmod 777 -R . chown -R $(id -u):$(id -g) . diff --git a/docker/app.setup.sh b/docker/app.setup.sh index 371cedfa..82a9def9 100644 --- a/docker/app.setup.sh +++ b/docker/app.setup.sh @@ -13,6 +13,8 @@ set +u # Ensure mysql is loaded dockerize -wait tcp://${DB_HOST}:${DB_HOST_PORT:-3306} -timeout 1m +source _lib.sh + # Config WordPress if [ ! -f "${WP_ROOT_FOLDER}/wp-config.php" ]; then wp config create \ @@ -44,3 +46,7 @@ if ! $(wp core is-installed --allow-root); then fi echo "Running WordPress version: $(wp core version --allow-root) at $(wp option get home --allow-root)" + +ls -l /var/www/html/wp-content/plugins/ +cd "${WP_ROOT_FOLDER}" +install_plugins