Skip to content

Commit

Permalink
chore: optimize dockerfile (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine authored Jul 11, 2022
1 parent b743b8c commit 16c3438
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 57 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

.git
.idea
bin
docker-output
docs
img
Expand Down
58 changes: 42 additions & 16 deletions bin/_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions bin/install-stan-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ source ${BASEDIR}/_lib.sh
install_wordpress
install_db
configure_wordpress

cd $WP_CORE_DIR
install_plugins

post_setup
3 changes: 3 additions & 0 deletions bin/install-test-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ source ${BASEDIR}/_lib.sh
install_wordpress
install_db
configure_wordpress

cd $WP_CORE_DIR
install_plugins

setup_plugin
post_setup
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -52,3 +55,6 @@ services:
networks:
local:
testing:

volumes:
wpdata:
1 change: 1 addition & 0 deletions docker/app.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 1 addition & 40 deletions docker/app.post-setup.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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) .
6 changes: 6 additions & 0 deletions docker/app.setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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

0 comments on commit 16c3438

Please sign in to comment.