-
Download the file
composer
to/usr/local/bin/composer
1.1.
curl -o /usr/local/bin/composer -L https://gist.githubusercontent.com/giordanocardillo/3111bfd5543813227008f140201d7135/raw/composer
-
chmod a+x /usr/local/bin/composer
to make executable -
Run
composer
-
Enjoy
Last active
June 20, 2017 13:48
-
-
Save giordanocardillo/3111bfd5543813227008f140201d7135 to your computer and use it in GitHub Desktop.
Using composer with docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
IMAGE="composer/composer:alpine" | |
# Setup options for connecting to docker host | |
if [ -z "$DOCKER_HOST" ]; then | |
DOCKER_HOST="/var/run/docker.sock" | |
fi | |
if [ -S "$DOCKER_HOST" ]; then | |
DOCKER_ADDR="-v $DOCKER_HOST:$DOCKER_HOST -e DOCKER_HOST" | |
else | |
DOCKER_ADDR="-e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH" | |
fi | |
# Setup volume mounts for context | |
if [ "$(pwd)" != '/' ]; then | |
VOLUMES="-v $(pwd):$(pwd)" | |
fi | |
# TODO: also check --file argument | |
if [ -n "$HOME" ]; then | |
VOLUMES="$VOLUMES -v $HOME:$HOME -v $HOME:/root" # mount $HOME in /root to share docker.config | |
fi | |
# Only allocate tty if we detect one | |
if [ -t 1 ]; then | |
DOCKER_RUN_OPTIONS="-t" | |
fi | |
if [ -t 0 ]; then | |
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i" | |
fi | |
exec docker run --rm $DOCKER_RUN_OPTIONS $DOCKER_ADDR $VOLUMES -w "$(pwd)" $IMAGE "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment