You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should use Multistage builds and copy your resulting files over to their respective locations. Here's a loose example of how we're doing it. There are better ways, but I slapped this together for illustrative purposes:
ARG PHP_VERSION=8.1
ARG NODE_VERSION=18
# Step 1 -- Composer
FROM php:${PHP_VERSION}-cli-alpine AS builder
WORKDIR /app
COPY --from=composer:2.3.3 /usr/bin/composer /usr/local/bin
COPY composer.json composer.lock ./
RUN composer install --no-dev
# Step 2 -- Theme
FROM node:${NODE_VERSION}-slim AS theme
WORKDIR /theme
COPY web/app/themes/custom-theme ./
RUN npm install && npm run build
# Step 3 -- PHP FPM
FROM wordpress:php${PHP_VERSION}-fpm-alpine AS final
COPY . .
COPY --from=builder --chown=www-data:www-data /app ./
COPY --from=theme --chown=www-data:www-data /theme/dist /var/www/html/web/app/themes/custom-theme/dist
ENTRYPOINT ["php-fpm"]
Activity
[-]Remove volume instruction[/-][+]Missing composer vendor folder[/+]spriya757 commentedon Oct 19, 2023
When using this image in our builds, we noticed that the vendor folder created by composer command in /var/www/html is being removed in the next layer.
Noticed the image has a VOLUME instruction - https://github.com/docker-library/wordpress/blob/master/latest/php8.2/fpm/Dockerfile#L142. Removing this and rebuilding the base image fixed the problem.
maiorano84 commentedon Nov 14, 2023
You're using Bedrock I'm assuming?
You should use Multistage builds and copy your resulting files over to their respective locations. Here's a loose example of how we're doing it. There are better ways, but I slapped this together for illustrative purposes: