Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 43 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#p Testing image used for GitLab CI
# Multi-stage build for Node.js
FROM node:24-slim AS node-stage

# Testing image used for GitLab CI
FROM php:8.3-apache AS base

# Install Node.js 24 (includes npm)
RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - && \
apt-get install -y --no-install-recommends nodejs
# Copy Node.js binaries and modules from the official Node.js image
COPY --from=node-stage /usr/local/bin/node /usr/local/bin/
COPY --from=node-stage /usr/local/lib/node_modules /usr/local/lib/node_modules
# Create symlinks for npm and npx
RUN ln -sf /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm && \
ln -sf /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx

RUN apt-get install -y --no-install-recommends \
# Install system packages and clean up in a single layer
RUN apt-get update && apt-get install -y --no-install-recommends \
libsodium-dev \
libpng-dev \
libjpeg-dev \
Expand All @@ -23,8 +30,12 @@ RUN apt-get install -y --no-install-recommends \
ca-certificates \
sudo \
git \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/doc/* \
/usr/share/man/*

# Configure GD with jpeg and freetype support
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
Expand All @@ -43,40 +54,44 @@ RUN docker-php-ext-install -j$(nproc) \
dom \
simplexml

RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* \
/tmp/* \
/var/tmp/* \
/usr/share/doc/* \
/usr/share/man/*

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

# Enable Apache mod_rewrite (if needed)
RUN a2enmod rewrite

# Set high limit for CLI (unlimited)
RUN echo "memory_limit = -1" > /usr/local/etc/php/conf.d/cli-memory.ini
# Set reasonable limit for Apache
RUN echo "memory_limit = 512M" > /usr/local/etc/php/conf.d/apache-memory.ini

# Install Playwright OS dependencies.
RUN npx playwright install-deps
# Configure Apache and PHP in a single layer
RUN a2enmod rewrite && \
echo "memory_limit = -1" > /usr/local/etc/php/conf.d/cli-memory.ini && \
echo "memory_limit = 512M" > /usr/local/etc/php/conf.d/apache-memory.ini

# Used for PHPUnit functional tests.
RUN CHROME_VERSION=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.version') && \
# Install Chrome and ChromeDriver for PHPUnit functional tests
RUN set -eux; \
CHROME_VERSION=$(curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.version') && \
curl -L "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chrome-linux64.zip" -o chrome-linux64.zip && \
unzip chrome-linux64.zip -d /opt/ && \
ln -sf /opt/chrome-linux64/chrome /usr/local/bin/google-chrome && \
curl -L "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chromedriver-linux64.zip" -o chromedriver-linux64.zip && \
unzip chromedriver-linux64.zip -d /usr/local/bin/ && \
mv /usr/local/bin/chromedriver-linux64/chromedriver /usr/local/bin/ && \
chmod +x /usr/local/bin/chromedriver && \
# Clean up downloads in same layer
rm -f chrome-linux64.zip chromedriver-linux64.zip && \
rm -rf /usr/local/bin/chromedriver-linux64/

# Use current date to bust cache
# Install current browsers
RUN date > /tmp/cache-bust && npx playwright install --with-deps
# Install Playwright with dependencies (cache-busted for latest browsers)
RUN set -eux; \
date > /tmp/cache-bust && \
npx playwright install --with-deps && \
# Clean up in same layer to reduce size (including Playwright cache!)
rm -f /tmp/cache-bust && \
rm -rf /tmp/* \
/var/tmp/* \
/var/lib/apt/lists/* \
~/.npm \
/root/.cache \
/usr/share/doc/* \
/usr/share/man/* \
/usr/share/locale/* \
/usr/share/pixmaps/* \
/usr/share/icons/hicolor/*/apps/* \
/var/cache/debconf/*

WORKDIR /var/www/html