Skip to content

Instantly share code, notes, and snippets.

@elysium001
Last active September 10, 2023 01:22
Show Gist options
  • Save elysium001/696dea70c6235a4d3c2e2ce8ca0a5387 to your computer and use it in GitHub Desktop.
Save elysium001/696dea70c6235a4d3c2e2ce8ca0a5387 to your computer and use it in GitHub Desktop.
Quick Dockerfile for php and composer
# Generated using Google Bard with prompt:
# generate a dockerfile that does the following:
# uses composer image to execute composer install on a given directory
# uses a nodejs image to execute npm install && npm run build on a given directory
# copies the composer and nodejs output to a PHP image that runs WordPress
# composer task
FROM composer:latest AS composer
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install
# nodejs task
FROM node:16-alpine AS nodejs
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install && npm run build
FROM php:8.1-fpm
WORKDIR /var/www/html
# TODO: copy wordpress steps here...
# copy output to new php image
COPY --from=composer /app/vendor/ ./vendor/
COPY --from=nodejs /app/public/ ./public/
EXPOSE 80
CMD ["php-fpm"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment