From d3a7e0fad06b93cdb2828e3d8c30db341b780f38 Mon Sep 17 00:00:00 2001 From: _Tradam Date: Wed, 17 Sep 2025 20:24:00 +0900 Subject: download wordpress if it doesnt already exist --- entrypoint.sh | 20 ++++++++++++++++++++ php.dockerfile | 8 ++++++++ 2 files changed, 28 insertions(+) create mode 100644 entrypoint.sh 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"] -- cgit v1.2.3