summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
author_Tradam <[email protected]>2025-09-17 20:24:00 +0900
committer_Tradam <[email protected]>2025-09-17 20:24:00 +0900
commitd3a7e0fad06b93cdb2828e3d8c30db341b780f38 (patch)
treeeb2a29f7a76eb2609cade5ca7570e6e6db34482a
parent213fb58da23d3c58b6924a1b96b6322c6d775e3e (diff)
downloadwordpress-docker-main.tar.gz
wordpress-docker-main.zip
download wordpress if it doesnt already existHEADmain
-rw-r--r--entrypoint.sh20
-rw-r--r--php.dockerfile8
2 files changed, 28 insertions, 0 deletions
diff --git a/entrypoint.sh b/entrypoint.sh
new file mode 100644
index 0000000..03d3b63
--- /dev/null
+++ b/entrypoint.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+set -e
+
+# Path where WordPress should live
+WP_PATH="/var/www/html"
+
+# Check if directory is empty
+if [ -z "$(ls -A $WP_PATH)" ]; then
+ echo "WordPress directory empty, downloading 6.8.2 WordPress..."
+ curl -O https://wordpress.org/wordpress-6.8.2.zip
+ tar -xzf latest.tar.gz --strip-components=1
+ rm latest.tar.gz
+ chown -R www-data:www-data $WP_PATH
+ echo "WordPress downloaded successfully."
+else
+ echo "WordPress already exists, skipping download."
+fi
+
+# Execute the container's main command (php-fpm)
+exec "$@"
diff --git a/php.dockerfile b/php.dockerfile
index 2a7db45..f7cd346 100644
--- a/php.dockerfile
+++ b/php.dockerfile
@@ -5,3 +5,11 @@ RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mys
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
RUN chmod +x wp-cli.phar && mv wp-cli.phar /usr/local/bin/wp
+
+WORKDIR /var/www/html
+
+COPY entrypoint.sh /usr/local/bin/entrypoint.sh
+RUN chmod +x /usr/local/bin/entrypoint.sh
+
+ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
+CMD ["php-fpm"]