New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a docker-php-composer-install script #260

Closed
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@mathroc
Contributor

mathroc commented Jul 14, 2016

As discussed in #177 composer is not the official php dependency manager but it's the de facto standard

This PR proposes to make it really easy to install composer "the right way"

This also makes it possible to install different version (stable, preview, snapshot) of composer

⚡ docker run --rm php:7-alpine docker-php-composer-install --help
Composer Installer

Options
--help this help
--check for checking environment only
--force forces the installation
--ansi force ANSI color output
--no-ansi disable ANSI color output
--quiet do not output unimportant messages
--install-dir="..." accepts a target installation directory
--preview install the latest version from the preview (alpha/beta/rc) channel instead of stable
--snapshot install the latest version from the snapshot (dev builds) channel instead of stable
--version="..." accepts a specific version to install instead of the latest
--filename="..." accepts a target filename (default: composer.phar)
--disable-tls disable SSL/TLS security for file downloads
--cafile="..." accepts a path to a Certificate Authority (CA) certificate file for SSL/TLS verification

Dockerfile usage exemple:

FROM php:7-alpine

RUN docker-php-composer-install && composer global require phpunit/phpunit

todo:

  • add docker-php-composer-install script
  • add script to images
  • documentation
  • set env var "COMPOSER_ALLOW_SUPERUSER" to remove warning about running composer as root
  • add /root/.composer/vendor/bin/ to $PATH
  • run update.sh

Do you think this can be a good solution ?

mathroc added a commit to mathroc/docs that referenced this pull request Jul 14, 2016

Add explanation to php for `docker-php-composer-install`
Depends on docker-library/php#260 making it into docker-library/official-images

mathroc added a commit to mathroc/docs that referenced this pull request Jul 14, 2016

Add explanation to php for `docker-php-composer-install`
Depends on docker-library/php#260 making it into docker-library/official-images
@mathroc

This comment has been minimized.

Show comment
Hide comment
@mathroc

mathroc Jul 26, 2016

Contributor

should I install the latest version of composer by default ? (#177 (comment))

Contributor

mathroc commented Jul 26, 2016

should I install the latest version of composer by default ? (#177 (comment))

@mathroc

This comment has been minimized.

Show comment
Hide comment
@mathroc

mathroc Sep 3, 2016

Contributor

I've updated the PR to resolves pending conflicts. is there anything I can do to help making a decision about including composer or not in this image ?

Contributor

mathroc commented Sep 3, 2016

I've updated the PR to resolves pending conflicts. is there anything I can do to help making a decision about including composer or not in this image ?

mathroc added a commit to mathroc/docs that referenced this pull request Sep 3, 2016

Add explanation to php for `docker-php-composer-install`
Depends on docker-library/php#260 making it into docker-library/official-images

mathroc added a commit to mathroc/docs that referenced this pull request Sep 3, 2016

Add explanation to php for `docker-php-composer-install`
Depends on docker-library/php#260 making it into docker-library/official-images

mathroc added a commit to mathroc/docs that referenced this pull request Sep 3, 2016

Add explanation to php for `docker-php-composer-install`
Depends on docker-library/php#260 making it into docker-library/official-images
@yosifkit

This comment has been minimized.

Show comment
Hide comment
@yosifkit

yosifkit Sep 10, 2016

Member

I am not sure we had concluded that composer should be included in the PHP images and I don't see much of a difference between installing it and installing a script to install it. In either case we are sanctioning composer and inviting issues in dealing with "using composer in docker". Perhaps we just need to add this script as an example to the docs?

Member

yosifkit commented Sep 10, 2016

I am not sure we had concluded that composer should be included in the PHP images and I don't see much of a difference between installing it and installing a script to install it. In either case we are sanctioning composer and inviting issues in dealing with "using composer in docker". Perhaps we just need to add this script as an example to the docs?

@mathroc

This comment has been minimized.

Show comment
Hide comment
@mathroc

mathroc Oct 24, 2016

Contributor

yeah, I know that's nothing is set in stone yet. If adding it into the image is not an option, yeah, maybe adding that to the doc is better than nothing.
but honestly, it would be a pita to go to the doc each time I want to install docker inside a php image. plus, this PR also add an env var & update $PATH.

the difference between adding RUN docker-php-composer-install and copying and pasting the whole script + adding the env var and modifying $PATH is quite big

also, improvements to the script would need to be discovered manually and wouldn't come with a docker pull php

Contributor

mathroc commented Oct 24, 2016

yeah, I know that's nothing is set in stone yet. If adding it into the image is not an option, yeah, maybe adding that to the doc is better than nothing.
but honestly, it would be a pita to go to the doc each time I want to install docker inside a php image. plus, this PR also add an env var & update $PATH.

the difference between adding RUN docker-php-composer-install and copying and pasting the whole script + adding the env var and modifying $PATH is quite big

also, improvements to the script would need to be discovered manually and wouldn't come with a docker pull php

@sylus sylus referenced this pull request Oct 24, 2016

Closed

Clean Up #108

@alcohol

This comment has been minimized.

Show comment
Hide comment
@alcohol

alcohol Oct 24, 2016

Could be a nice addition. I started on https://github.com/composer/docker but kind of lost track/motivation. Composer is just so easy to install/pull in, not sure it needs a container by itself. Also lots of discussion on whether or not it should come with a gazillion php extensions and what not. As part of the PHP base image, a lot of that discussion would be void since most users want to extend the php base image for their own app anyway.

Just wondering; wouldn't it make sense to add the composer home directory inside the container and specify it through the environment as well (e.g. COMPOSER_HOME=/composer) and then exposing this as a named volume? Would make cache and such a bit more persistent by default.

alcohol commented Oct 24, 2016

Could be a nice addition. I started on https://github.com/composer/docker but kind of lost track/motivation. Composer is just so easy to install/pull in, not sure it needs a container by itself. Also lots of discussion on whether or not it should come with a gazillion php extensions and what not. As part of the PHP base image, a lot of that discussion would be void since most users want to extend the php base image for their own app anyway.

Just wondering; wouldn't it make sense to add the composer home directory inside the container and specify it through the environment as well (e.g. COMPOSER_HOME=/composer) and then exposing this as a named volume? Would make cache and such a bit more persistent by default.

@alcohol alcohol referenced this pull request Nov 23, 2016

Merged

add composer #2290

9 of 9 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment