-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wp within the container (#150)
**Refactor Acore-CMS: Docker Compose as the Sole Installation Method** This pull request introduces a significant refactoring of Acore-CMS to standardize **Docker Compose** as the only supported installation method. By removing the WordPress sources (a common cause of conflicts with other forks) from the repository, we simplify the setup process and ensure seamless installation of WordPress and required plugins via WP-CLI. ### **Changes** - Removed WordPress sources from the repository. - Moved `acore-wp-plugin` under the `src` folder. - Implemented automatic installation of required plugins (e.g., WooCommerce, myCred, WP-GraphQL). - Fixed Redis integration. - Set `wordpress:6.7.1-php8.3-fpm` as the default WordPress version. - Updated README.md
- Loading branch information
Showing
5,651 changed files
with
309 additions
and
1,600,764 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"xdebug.php-pack" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
docker compose stop | ||
|
||
docker_container_name="php" | ||
|
||
# Get the container ID for the 'php' service (running or stopped) | ||
php_container_id=$(docker ps -a -q --filter "name=-$docker_container_name") | ||
|
||
# Check if the container exists (even if stopped) | ||
if [ -z "$php_container_id" ]; then | ||
echo "No container found for the '$docker_container_name' service (running or stopped)." | ||
exit 1 | ||
fi | ||
|
||
# Retrieve the full container name | ||
php_container_name=$(docker inspect -f '{{.Name}}' "$php_container_id" | sed 's/^\/\+//') | ||
|
||
# Extract the prefix from the container name (everything before '_php') | ||
php_container_prefix=$(echo "$php_container_name" | sed "s/-$docker_container_name.*//") | ||
|
||
echo "Container Prefix: $php_container_prefix" | ||
|
||
# Use the prefix for volume operations | ||
docker run --rm -v "${php_container_prefix}_wordpress-src:/var/www/html" -v "$(pwd)/srv:/srv" alpine sh -c "cp -r /srv/* /var/www/html/ && ls -l /var/www/html/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
# Function to check if a plugin is installed | ||
is_plugin_installed() { | ||
wp plugin is-installed "$1" --allow-root | ||
return $? | ||
} | ||
|
||
# Function to install and activate a plugin if not already installed | ||
install_and_activate_plugin() { | ||
local plugin_name="$1" | ||
local plugin_slug="$2" | ||
|
||
if ! is_plugin_installed "$plugin_slug"; then | ||
echo "Installing and activating plugin: $plugin_name..." | ||
wp plugin install "$plugin_slug" --activate --allow-root | ||
else | ||
echo "Plugin $plugin_name is already installed." | ||
fi | ||
} | ||
|
||
# Special handling for plugin activations that should only be done once | ||
handle_plugin_activation_once() { | ||
local plugin_slug="$1" | ||
local activation_flag="/usr/src/wordpress/.${plugin_slug}.activated" | ||
|
||
if [ -f "$activation_flag" ]; then | ||
echo "Plugin $1 has already been activated; skipping." | ||
return | ||
fi | ||
|
||
if is_plugin_installed "$plugin_slug"; then | ||
if ! wp plugin is-active "$plugin_slug" --allow-root; then | ||
echo "Activating plugin: $1..." | ||
wp plugin activate "$plugin_slug" --allow-root | ||
# Mark as activated | ||
touch "$activation_flag" | ||
else | ||
echo "Plugin $1 is already active." | ||
# Mark as activated if not marked already | ||
touch "$activation_flag" | ||
fi | ||
else | ||
echo "Plugin $1 is not installed; skipping." | ||
fi | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/bin/bash | ||
|
||
# List of plugins to install | ||
# Array semplice con nome e slug separati da "|" | ||
plugins_install=( | ||
"WooCommerce|woocommerce" | ||
"WPGraphQL|wp-graphql" | ||
"WPGraphQL ACF|wpgraphql-acf" | ||
"myCred|mycred" | ||
"Advanced Custom Fields|advanced-custom-fields" | ||
) | ||
|
||
# List of plugins to activate only once | ||
plugins_activate_only=( | ||
"ACore WP Plugins|acore-wp-plugins" | ||
) | ||
|
||
CURPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# Wait for the database to be available | ||
echo "Waiting for database to be ready..." | ||
until nc -z -v -w30 wp-db 3306; do | ||
echo "Waiting for database connection..." | ||
sleep 5 | ||
done | ||
echo "Database is ready!" | ||
|
||
# Execute the entrypoint script with the php-fpm command (use -v to only print the version and exit) | ||
bash /usr/local/bin/docker-entrypoint.sh "php-fpm" "-v" | ||
|
||
# Create the WordPress configuration file if it doesn't exist | ||
if [ ! -f /var/www/html/wp-config.php ]; then | ||
echo "Creating wp-config.php..." | ||
wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=wp-db --allow-root | ||
fi | ||
|
||
# Perform the initial WordPress installation if it hasn't been installed yet | ||
if ! wp core is-installed --allow-root; then | ||
echo "Installing WordPress..." | ||
wp core install --url="$WORDPRESS_URL" --title="$WORDPRESS_TITLE" --admin_user="$WORDPRESS_ADMIN_USER" --admin_password="$WORDPRESS_ADMIN_PASSWORD" --admin_email="$WORDPRESS_ADMIN_EMAIL" --allow-root | ||
fi | ||
|
||
wp maintenance-mode activate --allow-root | ||
|
||
# Install and activate plugins | ||
echo "Installing and activating plugins..." | ||
|
||
source "$CURPATH/init.lib.sh" | ||
|
||
# Install and activate each plugin in the list | ||
for plugin in "${plugins_install[@]}"; do | ||
# Dividi il nome e lo slug | ||
IFS='|' read -r plugin_name plugin_slug <<< "$plugin" | ||
|
||
echo "Installing $plugin_name ($plugin_slug)..." | ||
install_and_activate_plugin "$plugin_name" "$plugin_slug" | ||
done | ||
|
||
# Handle Acore WP Plugins activation | ||
for plugin in "${plugins_activate_only[@]}"; do | ||
IFS='|' read -r plugin_name plugin_slug <<< "$plugin" | ||
|
||
echo "Activating $plugin_name ($plugin_slug) only once..." | ||
handle_plugin_activation_once "$plugin_slug" | ||
done | ||
|
||
# Correct permissions for non-root operations | ||
chown -R www-data:www-data /run /var/www/html/ | ||
|
||
setfacl -R -m u:$DOCKER_USER_ID:rwx /var/www/html/ | ||
setfacl -R -d -m u:$DOCKER_USER_ID:rwx /var/www/html/ | ||
|
||
# Start a proxy from 127.0.0.1:6379 to the Redis container | ||
socat TCP-LISTEN:6379,fork TCP:redis:6379 & | ||
|
||
wp maintenance-mode deactivate --allow-root | ||
|
||
exec "php-fpm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.