Skip to content

Optimize image size #4

@mglaman

Description

@mglaman

The following step isn't reducing the layer sizes:

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

This layer is 265MB

# 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

We could copy the binaries from a Node image using

FROM node:24 as node
ENV npm_config_ignore_scripts=true
ENV YARN_ENABLE_SCRIPTS=false

FROM php:8.3-apache AS base

COPY --from=node /usr/local/bin /usr/local/bin
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules

We should clean up in this same layer as well. It's 802MB, not sure how much it can be trimmed down.

# Install Playwright OS dependencies.
RUN npx playwright install-deps

Actually I think we should restructure this:

# 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 Playwright OS dependencies.
RUN npx playwright install-deps && \
	date > /tmp/cache-bust && npx playwright install --with-deps && \
	&& apt-get clean && \
    rm -rf /var/lib/apt/lists/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions