Skip to content

Image providing PHP and composer for build purposes (used by the Beach builder.)

License

Notifications You must be signed in to change notification settings

flownative/docker-composer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT license Maintenance level: Love

Composer Docker Image

This Docker image provides Composer based on the Flownative Beach PHP images. By configuring your shell you can use this image as a replacement for a regular locally installed Composer.

You may want to use this solution if you need to maintain projects using Composer and Local Beach or Flownative Beach, because the PHP images used for the development and hosting environment will be exactly the same like the one used as a base for this image.

Shell Configuration

To simplify the docker run calls, you may want to configure your shell to do the heavy lifting for you. The easiest way is to declare functions in your .bashrc, .zshrc or other shell profile.

For example, in order to use Composer based on PHP 7.4 with ZSH, add the following to your .zshrc or the like:

composer74 () {
    tty=
    tty -s && tty=--tty
    docker run \
        $tty \
        --interactive \
        --rm \
        --user $(id -u):$(id -g) \
        --volume /etc/passwd:/etc/passwd:ro \
        --volume /etc/group:/etc/group:ro \
        --volume $(pwd):/application:delegated \
        --volume $HOME/.composer/cache:/home/composer/cache:delegated \
        --volume $HOME/.composer/auth.json:/home/composer/auth.json \
        flownative/composer:7.4 "$@"
}

Now you can run Composer simply by running something like the following:

composer74 -v update

Private Packagist

If dependencies are located in Private Packagist, you need to provide the HTTP Basic Auth credentials to the Composer container via the COMPOSER_AUTH environment variable. Credentials are provided as a JSON string ( see Composer documentation).

composer74 () {
    tty=
    tty -s && tty=--tty
    docker run \
        $tty \
        --interactive \
        --rm \
        --user $(id -u):$(id -g) \
        -e COMPOSER_AUTH="{"http-basic":{"repo.packagist.com":{"username":"token","password":"a524b…8ace"}}" \
        --volume /etc/passwd:/etc/passwd:ro \
        --volume /etc/group:/etc/group:ro \
        --volume $(pwd):/application:delegated \
        --volume $HOME/.composer/cache:/home/composer/cache:delegated \
        --volume $HOME/.composer/auth.json:/home/composer/auth.json \
        flownative/composer:7.4 "$@"
}

About

Image providing PHP and composer for build purposes (used by the Beach builder.)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •