GithubHelp home page GithubHelp logo

robloach / docker-composer Goto Github PK

View Code? Open in Web Editor NEW
104.0 7.0 51.0 225 KB

:ok_woman: Docker container to install and run Composer.

Home Page: https://hub.docker.com/r/library/composer/

License: Other

Makefile 63.18% Shell 36.82%

docker-composer's Introduction

DEPRECATED

This image has been deprecated and moved to the official composer Docker Container. See the source for more information.

Supported tags and respective Dockerfile links

  • 1.0
  • 1.0-alpine
  • 1.0-php5
  • 1.0-php5-alpine
  • 1.1, 1, latest
  • 1.1-php5, 1-php5, php5
  • 1.1-alpine, 1-alpine, alpine
  • 1.1-php5-alpine, 1-php5-alpine, php5-alpine
  • master
  • master-php5
  • master-alpine
  • master-php5-alpine, master-php7.1.4-alpine

What is Composer?

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

wikipedia.org/wiki/Composer (software)

Composer Logo

How to use this image.

Installation / Usage

  1. Install the composer/composer container:

    $ docker pull composer/composer

Alternatively, pull a specific version of composer/composer: sh $ docker pull composer/composer:1.1

  1. Create a composer.json defining your dependencies. Note that this example is a short version for applications that are not meant to be published as packages themselves. To create libraries/packages please read the documentation.

    {
        "require": {
            "monolog/monolog": ">=1.0.0"
        }
    }
  2. Run Composer through the Composer container:

    $ docker run --rm -v $(pwd):/app composer/composer install

Or run using a specific version of Composer: sh $ docker run --rm -v $(pwd):/app composer/composer:1.1 install If working with packages installed via git ssh the local .ssh directory shall be mapped into the container: sh $ docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer install

  1. Add optional composer command to the host (tested on OS X El Capitan with docker-machine)

Create new composer file sh $ sudo vim /usr/local/bin/composer

The contents of the file will look like this: sh #!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin echo "Current working directory: '"$(pwd)"'" docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh -v $HOME/.composer-docker:/composer composer/composer $@

Once the script has been made, it must be set as executable sh $ sudo chmod +x /usr/local/bin/composer

Now the composer command is available native on host: sh $ composer --version

Image Variants

composer/composer:<version>

This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.

composer/composer:php5

This is made to run Composer through PHP 5, rather then the default of PHP 7.

composer/composer:alpine

This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

composer/composer:php5-alpine

This is made to run Composer through PHP 5, rather then the default of PHP 7, through the Alpine container.

docker-composer's People

Contributors

derekbelrose avatar echernyavskiy avatar eugene-dounar avatar julienbreux avatar pherserk avatar pirog avatar robloach avatar saada avatar seldaek avatar sylus avatar webflo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-composer's Issues

ERROR: docker run --rm -v $PWD/:/app composer/composer install

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for mockery/mockery 0.9.4 -> satisfiable by mockery/mockery[0.9.4].
- mockery/mockery 0.9.4 requires hamcrest/hamcrest-php ~1.1 -> no matching package found.

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Too Many Deps

Why does the base composer images install so many php extensions and system deps? Are these really all required?

If they are, please let me know.

If they're there to cover general use-cases, I'll submit a PR to provide this in a more sophistiated manner.

Composer not looking at php container requirements

I am trying the composer image like this:

version: '2'
services:
  php:
    build: .
    volumes:
      - .:/var/www/html
  web:
    image: nginx
    ports:
      - "80:80"
    volumes:
      - .:/var/www/html
      - ./server.conf:/etc/nginx/conf.d/default.conf
    links:
      - php
  composer:
    image: 'composer/composer'
    volumes:
      - .:/var/www/html
    working_dir: /var/www/html
    command: update

When running docker-compose run composer, I'll get the following message:

Your requirements could not be resolved to an installable set of packages.

Next a list follows of unresolved requirements because some extensions of the framework are not installed. However, I installed them on my own build, which should be enough.

Any suggestions what I'm doing wrong?

In my opinion the composer image should only install composer and run the commands. Requirements of the machine are done in the php build....

Hash installer verifying error

Composer installer was updated, so using repository outdated code I had an error message : "Invalid installer". I checked base/Dockerfile validation use SHA hardcoded.

Is not a good idea using installer.sig for it ?

Something like:

RUN export COMPOSER_INSTALLER_SHA384=$(curl https://composer.github.io/installer.sig) \
  && php -r "readfile('https://getcomposer.org/installer');" > /tmp/composer-setup.php \
  && php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== '${COMPOSER_INSTALLER_SHA384}') { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }"

Custom ini files are ignored

Hello,

I tried to create a Symfony project using this docker container.
It fails while running the post-install-cmd scripts because date.timezone is not set.

This is caused by the fact that php ini dir is hard-coded and does not correspond to ini directory defines in php:5.6-cli docker container.

Add Documentation About GitHub Token

If I want to fetch a repository from github it fails. I think because credentials need to be passed to github.

 {
 "repositories": [
   {
     "type": "vcs",
     "url": "git://github.com/boedy/phinx.git"
   }
 ],
   "require": {
      "robmorgan/phinx": "dev-SQLite-bugfix"
  }
}

I get the following error. Is there a way that the credentials could be passed?

Failed to clone the [email protected]:boedy/phinx.git repository, try running in interactive mode so that you can enter your GitHub credentials

[RuntimeException]
Failed to execute git clone --mirror '[email protected]:boedy/phinx.git' '/root/composer/cache/vcs/git-github.com-boedy-phinx.git/'

mcrypt Extension not loaded although installed

I use the standard composer/composer build. It seems that the extension is installed and loaded. But in the phpinfo() the extension is not loaded / listed.

So if I install laravel via my composer container I get a error that the mcrypt extension is missing.

Output php -m:

[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
hash
iconv
json
libxml
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
recode
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

Dockerfile:

# Composer Docker Container
FROM php:5.6-cli
MAINTAINER Rob Loach <[email protected]>

ENV DEBIAN_FRONTEND noninteractive

# Dependencies
RUN echo "deb http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list
RUN echo "deb-src http://packages.dotdeb.org wheezy all" >> /etc/apt/sources.list
RUN curl http://www.dotdeb.org/dotdeb.gpg | apt-key add -
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y zlib1g zlib1g-dev php5-common git mercurial subversion
RUN apt-get install -y php5-curl php5-gd php5-json php5-mcrypt php5-mysql php5-pgsql php5-readline php5-sqlite sqlite3 mysql-client php5-mysql mcrypt php-pear

# Enable any modules
RUN php5enmod curl json mysql mysqli pdo_mysql pdo_sqlite readline gd mcrypt pdo sqlite3
RUN pecl install zip
RUN echo "extension=zip.so" > /usr/local/etc/php/conf.d/extension-zip.ini

# Set memory limit
RUN echo "memory_limit=1024M" > /usr/local/etc/php/conf.d/memory-limit.ini

# Set environmental variables
ENV COMPOSER_HOME /root/composer

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --version=1.0.0-alpha8

# Display version information
RUN php --version
RUN composer --version

# Set up the application directory.
VOLUME ["/app"]
WORKDIR /app

# Set up the command arguments
CMD ["-"]
ENTRYPOINT ["composer", "--ansi"]

--no-interaction appears to be implied

I've been experimenting with this layer to see if it would be usable in place of a local composer install, as well as as a container within a docker-compose specification. One thing I'm running into is that execution of it appears to imply the --no-interaction flag.

As an example, try the following:

$ docker run --rm -u $UID -v `pwd`:/app composer/composer create-project zendframework/skeleton-application zf3-via-docker

This project includes a couple of composer plugins, zend-component-installer and zend-skeleton-installer, which each normally have prompts to allow the developer to provide information (in the former case, to potentially add application configuration; in the latter, to modify dependencies). In both cases, as well, running without interaction triggers default actions (usually: do nothing), or, detects that work has already been done and do nothing.

When run with this docker layer, however, I can see the plugins being triggered, but am never given the expected prompts.

I've run composer within layers previously (we include it with the default Dockerfile in the ZF skeleton application, for instance), and it runs normally, prompting as expected.

I've combed through this repo, and cannot see that the flag is being passed; is there perhaps some other configuration file I'm missing?

tl;dr: I'd like to run composer with interaction.

Add support for php7

Php 7 is going to be released, why not to add a branch with php7 under the hood?

How to mount the composer cache into the container?

Hi,

I would like to share my host composer cache with the container cache. How can I proceed?
I have already tried the following :

docker run -ti -v $PWD:/data -w /data composer/composer install -w ~/.composer:/root/.composer --ignore-platform-reqs

How to add extension php-intl

How can I add php extension intl to composer? I got this error requires ext-intl * -> the requested PHP extension intl is missing from your system.

Official Repo

I was reading over: https://github.com/docker-library/official-images

and just wondering if over the next few weeks / months we were going to try to make this the official repo for composer? If the upstream folks are cool with that?

I think we just need to add a customized update.sh + generate-stackbrew-library.sh script which I am happy to start taking a look at, but wanted to check in first. ^_^

Add mcrypt

@Markcial asks...

what about missing modules like bcmath? why gd is in the container but there is no mcrypt for example?

Those would be great modules to add.

How could I make composer container execute in a other container?

From https://hub.docker.com/r/composer/composer/

akosgluebe said (3 months ago)
Hello,

It is shown how to make an alias: "Now the composer command is available native on host". Great.
How could I make this alias/this command available in a running container? Lets say I start up, for example, the latest jenkins container (or whatever other container), how could I use this composer inside that container? (I would like to avoid docker in docker)
Thanks!

i have same his question, can we run this in a other container ?
i see this problem a long time ago but can't think any simple resolution.

Anyone may suggest for me, thx :)

Add docker-compose example to README

Hi, I'm new to docker-compose and wanted to use this docker container in my project. I'm a little unsure what that would look like. Here's my best guess, can you advise?

php:
  build: ./php/
  links:
    - composer
# skipping lines . . .

composer:
  build: ./composer/
# etc...

And then inside of ./composer/ a Dockerfile like so

FROM composer/composer

# Use local composer.json file
COPY ./composer.json /var/www/html/composer.json
WORKDIR /var/www/html
RUN composer install

Thanks for the great project(s)!

Persistent mode with config watching

Hello. I'd like propose idea about persistent mode whenever something like gulp will watch that composer config has changed, and composer will re-update vendor components. It's useful for development stage.

Add support for bash entrypoint

Most docker containers have the ability support entering into bash by adding an entrypoint script.

Something like this will do:

entrypoint.sh

if [ "$1" == composer ]; then
  exec "composer --ansi ${@:2}"
else
  exec "$@"
fi

And in your Dockerfile

ADD entrypoint.sh /entrypoint.sh
CMD ["composer"]
ENTRYPOINT ["/entrypoint.sh"]

Need pcntl extension

This for PHPUnit which in turn (here at least) needs PHP/Invoker which requires pcntl.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpunit/php-invoker 1.1.4 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - phpunit/php-invoker 1.1.3 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - phpunit/php-invoker 1.1.2 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - phpunit/php-invoker 1.1.1 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
    - Installation request for phpunit/php-invoker * -> satisfiable by phpunit/php-invoker[1.1.1, 1.1.2, 1.1.3, 1.1.4].

Switch folder structure from x.x.x to x.x

I noticed most (not sure if all) of the official docker images are using a simplified folder structure. They only take the major.minor version and map that to a folder name. When the major.minor.patch is updated that gets reflected in the dockerfile but if the major.minor didn't change the folder name wouldn't.

Is this something we wanted to take a look at? Here are some examples showing all the tags still existing but folder structure a bit simplified in the repo:

Solr

https://github.com/docker-solr/docker-solr
https://hub.docker.com/r/library/solr/tags/

Postgres

https://github.com/docker-library/postgres
https://hub.docker.com/r/library/postgres/tags/

Node

https://github.com/nodejs/docker-node
https://hub.docker.com/r/library/postgres/tags/

I for sure might be missing something but thought would start discussion :)

Permissions

Hello,

If I use composer without changing any settings my vendor will get root:root 755 permissions.
If I use my own UID for user and/or group it will fail on writing into the cache.

Am I doing something wrong or is this the expected behaviour?

Missing ssh in Alpine version

When I run

docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer:alpine outdated

I get

  [RuntimeException]                                                                                                               
  Failed to execute git clone --mirror '[email protected]:repo/name.git' '/composer/cache/vcs/git-bitbucket.org-repo-name.git/'  
  Cloning into bare repository '/composer/cache/vcs/git-bitbucket.org-repo-name.git'...                                           
  error: cannot run ssh: No such file or directory                                                                                 
  fatal: unable to fork

The "latest" version is working fine.

Container does not work in Gitlab CI Runner

When trying to use composer/composer:php5-alpine in Gitlab CI, there is some odd error occuring:

The .gitlab-ci.yml looks like this:

image: composer/composer:php5-alpine
stages:
  - build
  - test
  - deploy
# Jobs
satis-build:
  stage: build
  script:
    - ls

and creates a build output like this:

gitlab-ci-multi-runner 1.3.2 (0323456)
Using Docker executor with image composer/composer:php5-alpine ...
Pulling docker image composer/composer:php5-alpine ...
Running on runner-420782f7-project-64-concurrent-0 via build-runner-githost...
Fetching changes...
HEAD is now at 8d19828 More tests
From https://gitlab.undpaul.de/undpaul/packages
   8d19828..9141eee  master     -> origin/master
Checking out 9141eee5 as master...


  [Symfony\Component\Console\Exception\RuntimeException]  
  The "-c" option does not exist.                         


show [--all] [-i|--installed] [-p|--platform] [-a|--available] [-s|--self] [-N|--name-only] [-P|--path] [-t|--tree] [-l|--latest] [-o|--outdated] [-D|--direct] [--] [<package>] [<version>]



  [Symfony\Component\Console\Exception\RuntimeException]  
  The "-c" option does not exist.                         


show [--all] [-i|--installed] [-p|--platform] [-a|--available] [-s|--self] [-N|--name-only] [-P|--path] [-t|--tree] [-l|--latest] [-o|--outdated] [-D|--direct] [--] [<package>] [<version>]


ERROR: Build failed: exit code 1

composer/composer:master image is out of date

The master image is version 1.0-dev (66acee7feb51d4b30e8983c703bf07ce1d06883e) 2015-09-12 22:04:37.

The latest composer version is 1.0-dev (a54f84f05f915c6d42bed94de0cdcb4406a4707b) 2015-10-13 13:09:04.

Among other changes it's missing out on the new --classmap-authoritative option for the install command.

It'd be great to automate updating of the master image when the composer project is updated.

Handle tags

Allow downloading of different versions through Composer.

run `laravel new blog` is failed

For the install instruction, I run below command to create a new project.

$ cat /usr/local/bin/composer
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
echo "Current working directory: '"$(pwd)"'"
docker run --rm -v $(pwd):/app -v ~/.ssh:/root/.ssh composer/composer $@

$ composer
Current working directory: '/Users/bill/composer'
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.0.0 2016-04-05 13:27:25

problem 1

If I run composer global require "laravel/installer", the command runs well, but there is no new folders generated.

So I have to manually created a composer.json file, and this time I got all vendor folders.

$ cat composer.json
{
    "require": {
        "laravel/installer": ">=1.3.3"
    }
}

$ composer install

problem 2

I need create a new project, I run below command:

$ vendor/bin/laravel new blog
...
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Generating autoload files
Application ready! Build something amazing.

I found the APP Key is not automatically generated, if I run the command manually:

$ php artisan key:generate

Warning: require(/Users/bill/composer/blog/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /Users/bill/composer/blog/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required '/Users/bill/composer/blog/bootstrap/../vendor/autoload.php' (include_path='.:') in /Users/bill/composer/blog/bootstrap/autoload.php on line 17

then I run with composer create-project --prefer-dist laravel/laravel blog, this time everything works fine.

$ composer create-project --prefer-dist laravel/laravel blog
...
phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader

Alpine Build Broken

ERROR: unsatisfiable constraints:
  php-pear (missing):
    required by: world[php-pear]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.