# ------------------------------------------------- # Stage 1 – build Composer‑based plugins # ------------------------------------------------- FROM php:8.2-cli AS builder RUN apt-get update && \ apt-get install -y --no-install-recommends unzip git && \ rm -rf /var/lib/apt/lists/* WORKDIR /app COPY composer.json composer.lock ./ RUN curl -sS https://getcomposer.org/installer | php && \ php composer.phar install --no-dev --optimize-autoloader && \ rm -f composer.json composer.lock # ------------------------------------------------- # Stage 2 – prepare the Indy WP theme (tar.gz version) # ------------------------------------------------- FROM php:8.2-apache AS theme-preparer RUN apt-get update && \ apt-get install -y --no-install-recommends wget tar && \ rm -rf /var/lib/apt/lists/* ARG THEME_TAG=v1.0.0 # expose the tag to the runtime (used by the entrypoint) ENV THEME_TAG=${THEME_TAG} ARG TAR_URL=https://codeberg.org/radioparalelo/indy-wp-theme/archive/${THEME_TAG}.tar.gz RUN wget -O /tmp/indy-wp-theme.tar.gz "${TAR_URL}" && \ tar -xzf /tmp/indy-wp-theme.tar.gz -C /tmp && \ rm /tmp/indy-wp-theme.tar.gz # ------------------------------------------------- # Stage 3 – final WordPress image # ------------------------------------------------- FROM wordpress:php8.2-apache # ---- Custom PHP config ------------------------------------------------- COPY config/php.ini /usr/local/etc/php/conf.d/custom.ini # ---- Install unzip & WP‑CLI -------------------------------------------- RUN apt-get update && \ apt-get install -y --no-install-recommends unzip && \ rm -rf /var/lib/apt/lists/* && \ 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 # ---- WP‑CLI cache folder ------------------------------------------------ RUN mkdir -p /var/www/.wp-cli && \ chown -R www-data:www-data /var/www/.wp-cli # ---- Copy plugins from builder ----------------------------------------- COPY --from=builder \ --chown=www-data:www-data \ /app/wp-content/plugins /var/www/html/wp-content/plugins # ---- Copy the theme ------------------------------------------------------ COPY --from=theme-preparer \ --chown=www-data:www-data \ /tmp/indy-wp-theme* /var/www/html/wp-content/themes/indy-wp-theme # ---- Permissions --------------------------------------------------------- USER www-data RUN mkdir -p /var/www/html/wp-content/uploads && \ chmod -R 755 /var/www/html/wp-content/plugins && \ chmod -R 755 /var/www/html/wp-content/themes && \ chmod -R 775 /var/www/html/wp-content/uploads # ---- Healthcheck --------------------------------------------------------- HEALTHCHECK --interval=30s --timeout=5s \ CMD curl -f http://localhost/wp-admin/ || exit 1 EXPOSE 80 # ---- Custom entrypoint scripts ------------------------------------------- COPY entrypoint.sh /usr/local/bin/ COPY entrypoint-theme.sh /usr/local/bin/ USER root RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/entrypoint-theme.sh USER www-data ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] CMD ["apache2-foreground"]