Skip to content

Instantly share code, notes, and snippets.

@ciaranmcnulty
Last active June 15, 2023 01:14
Show Gist options
  • Save ciaranmcnulty/1edcc70d3016a7927faec094ca307e9e to your computer and use it in GitHub Desktop.
Save ciaranmcnulty/1edcc70d3016a7927faec094ca307e9e to your computer and use it in GitHub Desktop.
PHP Dockerfile with composer target
FROM php:7.2.10-fpm-alpine3.8 AS base
# Stuff needed in all layers
RUN apk add --no-cache gettext fcgi icu-dev
RUN docker-php-ext-install bcmath
FROM base AS dependencies
COPY --from=composer:1.7 /usr/bin/composer /usr/bin/composer
COPY composer.json /app/composer.json
WORKDIR /app
RUN composer install -a -o --no-dev
FROM base as prod
# Assumes /vendor is in .dockerignore
COPY --from=dependencies /app/vendor /app/vendor
COPY . /app/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment