Skip to content

Commit a90a4ab

Browse files
committed
fix: plugin install
1 parent 396a970 commit a90a4ab

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

wordpress/Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli
1010
&& chmod +x wp-cli.phar \
1111
&& mv wp-cli.phar /usr/local/bin/wp
1212

13-
# Copy the revalidation plugin
14-
COPY next-revalidate /var/www/html/wp-content/plugins/next-revalidate
15-
16-
# Copy the headless redirect theme
17-
COPY theme /var/www/html/wp-content/themes/nextjs-headless
13+
# Copy plugin and theme to staging location (volume overwrites /var/www/html)
14+
COPY next-revalidate /usr/src/next-revalidate
15+
COPY theme /usr/src/nextjs-headless
1816

1917
# Copy the setup scripts
2018
COPY setup.sh /usr/local/bin/setup-wordpress.sh

wordpress/entrypoint.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
11
#!/bin/bash
22

3-
# Run the setup script in the background after a delay
4-
(sleep 30 && /usr/local/bin/setup-wordpress.sh) &
3+
# Copy plugin and theme from staging to WordPress (after volume is mounted)
4+
copy_custom_files() {
5+
# Wait for WordPress files to be ready
6+
while [ ! -d /var/www/html/wp-content/plugins ]; do
7+
sleep 2
8+
done
9+
10+
# Copy plugin if not already present
11+
if [ ! -d /var/www/html/wp-content/plugins/next-revalidate ]; then
12+
echo "Installing next-revalidate plugin..."
13+
cp -r /usr/src/next-revalidate /var/www/html/wp-content/plugins/
14+
chown -R www-data:www-data /var/www/html/wp-content/plugins/next-revalidate
15+
fi
16+
17+
# Copy theme if not already present
18+
if [ ! -d /var/www/html/wp-content/themes/nextjs-headless ]; then
19+
echo "Installing nextjs-headless theme..."
20+
cp -r /usr/src/nextjs-headless /var/www/html/wp-content/themes/
21+
chown -R www-data:www-data /var/www/html/wp-content/themes/nextjs-headless
22+
fi
23+
24+
# Run the setup script
25+
/usr/local/bin/setup-wordpress.sh
26+
}
27+
28+
# Run copy and setup in background after a delay
29+
(sleep 10 && copy_custom_files) &
530

631
# Run the original WordPress entrypoint
732
exec docker-entrypoint.sh "$@"

wordpress/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ if ! wp core is-installed --allow-root 2>/dev/null; then
2121
--allow-root
2222

2323
echo "WordPress installed successfully!"
24+
25+
# Remove default plugins (keep only next-revalidate)
26+
echo "Removing default plugins..."
27+
wp plugin delete akismet --allow-root 2>/dev/null || true
28+
wp plugin delete hello --allow-root 2>/dev/null || true
2429
fi
2530

2631
# Activate the revalidation plugin if not already active

0 commit comments

Comments
 (0)