ci: optimise docker workflows

This commit is contained in:
2025-11-01 17:04:03 +01:00
parent 46f17c5164
commit 6bf6bf4cbe
5 changed files with 887 additions and 41 deletions

View File

@@ -50,8 +50,8 @@ COPY tsconfig.json ./
# Build production assets
RUN npm run build
# Stage: Production Runtime
FROM php:8.5.0RC3-fpm AS production
# Stage: Runtime Base Image (shared)
FROM php:8.5.0RC3-fpm AS runtime-base
# Install system dependencies + nginx for production
RUN apt-get update && apt-get install -y \
@@ -71,7 +71,7 @@ RUN apt-get update && apt-get install -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install PHP extensions
# Install PHP extensions required at runtime
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
@@ -95,13 +95,17 @@ RUN docker-php-ext-install -j$(nproc) \
RUN pecl install apcu redis-6.3.0RC1 \
&& docker-php-ext-enable apcu redis
# Configure APCu
# Configure APCu defaults
RUN echo "apc.enable_cli=1" >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini \
&& echo "apc.shm_size=128M" >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
# Install Composer
# Install Composer into the runtime image for artisan usage
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Stage: Production Runtime
ARG RUNTIME_IMAGE=runtime-base
FROM ${RUNTIME_IMAGE} AS production
# Set working directory
WORKDIR /var/www/html
@@ -128,7 +132,7 @@ RUN mkdir -p storage/logs storage/cache storage/uploads \
&& chown -R www-data:www-data storage \
&& chmod -R 775 storage
# Copy entrypoint script for production
# Copy entrypoint script for production (overrides runtime base when rebuilt)
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh