75 lines
2.7 KiB
Docker
75 lines
2.7 KiB
Docker
FROM wordpress:php8.2-apache AS base
|
||
|
||
# -------------------------------------------------
|
||
# 1️⃣ Remove bundled themes (keep only core)
|
||
# -------------------------------------------------
|
||
RUN rm -rf /usr/src/wordpress/wp-content/themes/*
|
||
|
||
# -------------------------------------------------
|
||
# 2️⃣ Custom PHP config
|
||
# -------------------------------------------------
|
||
COPY config/php.ini /usr/local/etc/php/conf.d/custom.ini
|
||
|
||
# -------------------------------------------------
|
||
# 3️⃣ System utilities + Composer
|
||
# -------------------------------------------------
|
||
RUN apt-get update && \
|
||
apt-get install -y --no-install-recommends unzip && \
|
||
rm -rf /var/lib/apt/lists/* && \
|
||
curl -sS https://getcomposer.org/installer | \
|
||
php -- --install-dir=/usr/local/bin --filename=composer
|
||
|
||
# -------------------------------------------------
|
||
# 4️⃣ WP‑CLI
|
||
# -------------------------------------------------
|
||
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
||
chmod +x wp-cli.phar && \
|
||
mv wp-cli.phar /usr/local/bin/wp
|
||
|
||
WORKDIR /var/www/html
|
||
|
||
# -------------------------------------------------
|
||
# Give www-data ownership of WP‑CLI cache folder
|
||
# -------------------------------------------------
|
||
RUN mkdir -p /var/www/.wp-cli && chown -R www-data:www-data /var/www/.wp-cli
|
||
|
||
# -------------------------------------------------
|
||
# 5️⃣ (Removed) theme‑install step that caused the error
|
||
# -------------------------------------------------
|
||
|
||
# -------------------------------------------------
|
||
# 6️⃣ Writable uploads folder
|
||
# -------------------------------------------------
|
||
RUN mkdir -p wp-content/uploads && \
|
||
chown -R www-data:www-data wp-content && \
|
||
chmod -R 775 wp-content
|
||
|
||
# -------------------------------------------------
|
||
# 7️⃣ Composer‑based plugins (same as before)
|
||
# -------------------------------------------------
|
||
COPY composer.json composer.lock ./
|
||
RUN composer install --no-dev --optimize-autoloader && \
|
||
rm composer.json composer.lock && \
|
||
chown -R www-data:www-data wp-content/plugins && \
|
||
chmod -R 755 wp-content/plugins
|
||
|
||
# -------------------------------------------------
|
||
# 8️⃣ Healthcheck
|
||
# -------------------------------------------------
|
||
HEALTHCHECK --interval=30s --timeout=5s \
|
||
CMD curl -f http://localhost/wp-admin/install.php || exit 1
|
||
|
||
EXPOSE 80
|
||
|
||
# -------------------------------------------------
|
||
# 📜 Custom entrypoint (calls official one first)
|
||
# -------------------------------------------------
|
||
COPY entrypoint.sh /usr/local/bin/
|
||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||
|
||
COPY entrypoint-theme.sh /usr/local/bin/
|
||
RUN chmod +x /usr/local/bin/entrypoint-theme.sh
|
||
|
||
ENTRYPOINT ["entrypoint.sh"]
|
||
CMD ["apache2-foreground"]
|