php-composer is a php-cli based image with PHP & Docker extensions as well as composer preinstalled.
Docker images can be pulled using the Docker CLI.
docker pull stephenneal/php-composer:8.0-v1
Here's an example of a composer dependency installation portion of a Laravel Application's Dockerfile. Once composer packages have been installed, the relevant directories can be copied to the final image. Using a multi-step build allows the final image to be smaller by avoiding installing composer and its dependencies.
# Build temp image to install composer dependencies
ARG php_composer_tag=8.0-v1
FROM stephenneal/php-composer:${php_composer_tag} AS composer
# Set working directory
WORKDIR /var/www
# Laravel .env file
ARG env_file_name=.env
# Composer install flags
ARG composer_flags="--no-scripts --no-autoloader --no-dev"
# Copy composer & yarn package files
COPY ["composer.json", "composer.lock", "/var/www/"]
# Install composer dependencies
RUN composer install ${composer_flags}
Please see CONTRIBUTING for details.
If you discover any security related issues, please email stephen.neal14@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.