builder
This commit is contained in:
parent
261d872ce3
commit
f1d4f6a45e
1 changed files with 69 additions and 45 deletions
114
Dockerfile
114
Dockerfile
|
|
@ -1,9 +1,22 @@
|
|||
FROM php:8.5-fpm
|
||||
# ── Stage 1: CSS build ────────────────────────────────────────────────────────
|
||||
FROM node:22-slim AS node-build
|
||||
WORKDIR /build
|
||||
COPY package.json tailwind.config.js ./
|
||||
RUN npm install --include=dev
|
||||
# Copy only what Tailwind needs to scan + the input CSS
|
||||
COPY web/modules/custom/riverside_pt/css/tailwind.css \
|
||||
web/modules/custom/riverside_pt/css/tailwind.css
|
||||
COPY web/modules/custom/riverside_pt/templates/ \
|
||||
web/modules/custom/riverside_pt/templates/
|
||||
COPY web/modules/custom/riverside_pt/src/ \
|
||||
web/modules/custom/riverside_pt/src/
|
||||
COPY web/modules/custom/riverside_pt/js/components/ \
|
||||
web/modules/custom/riverside_pt/js/components/
|
||||
RUN npm run build
|
||||
|
||||
# ── Stage 2: PHP extensions + Composer deps ───────────────────────────────────
|
||||
FROM php:8.5-fpm AS php-build
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
nginx \
|
||||
supervisor \
|
||||
postgresql-client \
|
||||
libpq-dev \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
|
|
@ -11,77 +24,88 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||
libzip-dev \
|
||||
git \
|
||||
unzip \
|
||||
locales \
|
||||
curl \
|
||||
gettext-base \
|
||||
procps \
|
||||
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
|
||||
&& apt-get install -y nodejs \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN docker-php-ext-configure gd --with-freetype --with-jpeg && \
|
||||
docker-php-ext-install -j"$(nproc)" \
|
||||
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
||||
&& docker-php-ext-install -j"$(nproc)" \
|
||||
pdo_pgsql \
|
||||
pgsql \
|
||||
gd \
|
||||
zip \
|
||||
exif \
|
||||
bcmath
|
||||
bcmath \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN curl -fsSL https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
WORKDIR /var/www/html
|
||||
COPY composer.json ./
|
||||
|
||||
RUN composer config repositories.drupal composer https://packages.drupal.org/8 \
|
||||
&& composer require \
|
||||
composer/installers:^2.3 \
|
||||
drupal/core-recommended:^11 \
|
||||
drupal/core-composer-scaffold:^11 \
|
||||
"drush/drush:^13 || ^14" \
|
||||
drupal/webform \
|
||||
drupal/symfony_mailer \
|
||||
drupal/claro_compact \
|
||||
--no-update \
|
||||
&& composer install --no-dev --optimize-autoloader --no-interaction \
|
||||
&& rm -rf /root/.composer/cache
|
||||
|
||||
# ── Stage 3: Runtime image ────────────────────────────────────────────────────
|
||||
FROM php:8.5-fpm
|
||||
|
||||
# Runtime libs for the compiled PHP extensions (no dev headers).
|
||||
# If php:8.5-fpm is based on Debian Trixie, rename libpng16-16 → libpng16-16t64
|
||||
# and libzip4 → libzip4t64 if this apt-get step fails.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
nginx \
|
||||
supervisor \
|
||||
postgresql-client \
|
||||
libpq5 \
|
||||
libpng16-16 \
|
||||
libjpeg62-turbo \
|
||||
libfreetype6 \
|
||||
libzip4 \
|
||||
locales \
|
||||
curl \
|
||||
gettext-base \
|
||||
procps \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy compiled PHP extension .so files and their ini enablement files
|
||||
COPY --from=php-build /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
|
||||
COPY --from=php-build /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/
|
||||
|
||||
ENV PATH="/var/www/html/vendor/bin:${PATH}"
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Copy composer manifest first for layer caching; install pulls Drupal from Packagist.
|
||||
# To use ../drupal instead, add it as a path repository in composer.json:
|
||||
# "repositories": [{"type": "path", "url": "../drupal/core", "options": {"symlink": false}}]
|
||||
# then bump drupal/core-recommended to "11.x-dev@dev" and rebuild.
|
||||
COPY composer.json package.json tailwind.config.js ./
|
||||
# Copy scaffolded vendor + web/ from composer stage
|
||||
COPY --from=php-build /var/www/html/ ./
|
||||
|
||||
RUN npm install --include=dev
|
||||
|
||||
RUN composer config repositories.drupal composer https://packages.drupal.org/8
|
||||
|
||||
## Composer requires
|
||||
|
||||
|
||||
# Core
|
||||
RUN composer require composer/installers:^2.3 --no-update
|
||||
RUN composer require drupal/core-recommended:^11 --no-update
|
||||
RUN composer require drupal/core-composer-scaffold:^11 --no-update
|
||||
RUN composer require drush/drush:"^13 || ^14" --no-update
|
||||
|
||||
# Extra
|
||||
RUN composer require drupal/webform drupal/symfony_mailer drupal/claro_compact --no-update
|
||||
|
||||
#######
|
||||
|
||||
|
||||
RUN composer install --no-dev --optimize-autoloader --no-interaction
|
||||
|
||||
# Overlay our site-specific files on top of the scaffolded web/
|
||||
# Overlay site-specific files on top of the scaffolded web/
|
||||
COPY web/sites/default/settings.php web/sites/default/settings.php
|
||||
COPY web/sites/default/files/ web/sites/default/files/
|
||||
COPY web/modules/custom/ web/modules/custom/
|
||||
|
||||
RUN npm run build
|
||||
# Overwrite with the minified CSS built in the node stage
|
||||
COPY --from=node-build /build/web/modules/custom/riverside_pt/css/app.css \
|
||||
web/modules/custom/riverside_pt/css/app.css
|
||||
|
||||
ARG FULLCALENDAR_VERSION=6.1.15
|
||||
RUN curl -fsSL "https://cdn.jsdelivr.net/npm/fullcalendar@${FULLCALENDAR_VERSION}/index.global.min.js" \
|
||||
-o web/modules/custom/riverside_pt/js/fullcalendar.min.js
|
||||
|
||||
COPY config/sync/ config/sync/
|
||||
|
||||
# Debian nginx runs as www-data (matches php-fpm), config in conf.d/
|
||||
RUN rm -f /etc/nginx/sites-enabled/default
|
||||
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf.template
|
||||
|
||||
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY docker/php/entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
# Pass container env vars through to PHP-FPM workers; log errors to /var/log.
|
||||
RUN sed -i 's|;error_log = log/php-fpm.log|error_log = /var/log/php-fpm.log|' /usr/local/etc/php-fpm.conf && \
|
||||
{ \
|
||||
echo 'clear_env = no'; \
|
||||
|
|
|
|||
Loading…
Reference in a new issue