add php to the dockerfile

This commit is contained in:
Codex Agent
2025-11-15 15:37:39 +01:00
parent b928d2a68b
commit 4981d9f060

View File

@@ -4,24 +4,7 @@ ARG PHP_VERSION=8.3
ARG NODE_VERSION=20
################################################################################
# Node build stage - compile front-end assets
################################################################################
FROM node:${NODE_VERSION}-bookworm AS node_builder
WORKDIR /var/www/html
# install PHP CLI for Wayfinder
RUN apt-get update \
&& apt-get install -y --no-install-recommends php-cli php-mbstring php-xml php-curl \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci --no-audit --prefer-offline
COPY . .
RUN npm run build
################################################################################
# Composer dependencies
# Composer dependencies (install vendor/)
################################################################################
FROM composer:2 AS vendor
@@ -29,17 +12,34 @@ WORKDIR /var/www/html
COPY composer.json composer.lock ./
# Install production dependencies only, skip scripts (they run at runtime)
RUN composer install \
--no-dev \
--no-scripts \
--no-interaction \
--prefer-dist \
--optimize-autoloader \
--ignore-platform-req=ext-intl \
--ignore-platform-req=ext-pcntl \
--ignore-platform-req=ext-gd \
--ignore-platform-req=ext-imagick
--ignore-platform-reqs
COPY . .
################################################################################
# Node build stage - compile front-end assets (needs PHP + vendor)
################################################################################
FROM node:${NODE_VERSION}-bookworm AS node_builder
WORKDIR /var/www/html
RUN apt-get update \
&& apt-get install -y --no-install-recommends php-cli php-mbstring php-xml php-curl php-zip \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci --no-audit --prefer-offline
COPY . .
COPY --from=vendor /var/www/html/vendor ./vendor
RUN npm run build
################################################################################
# PHP-FPM runtime image
@@ -55,7 +55,6 @@ ENV APP_ENV=production \
WORKDIR /opt/app
# Install system dependencies & PHP extensions
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git \
@@ -81,28 +80,20 @@ RUN apt-get update \
pcntl \
pdo_mysql \
zip \
&& pecl install redis \
&& pecl install imagick \
&& pecl install redis imagick \
&& docker-php-ext-enable redis imagick \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy application source
COPY . .
# Copy vendor dependencies and build artifacts
COPY --from=vendor /var/www/html/vendor ./vendor
COPY --from=node_builder /var/www/html/public/build ./public/build
# Copy production php.ini overrides if present
COPY docker/php/php.ini /usr/local/etc/php/conf.d/app.ini
COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
# Entrypoint prepares deployment directory on persistent volume
COPY docker/app/entrypoint.sh /usr/local/bin/app-entrypoint
RUN chmod +x /usr/local/bin/app-entrypoint
EXPOSE 9000
ENTRYPOINT ["app-entrypoint"]
CMD ["php-fpm"]