docker-entrypoint.sh 984 Bytes
Newer Older
1 2 3 4
#!/bin/bash

set -e

5 6
SEMAPH=composer-running

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# if it's not already there, install composer.
if ! [ -e /usr/local/bin/composer ]; then
    echo >&2 "first getting Composer"
    # Get Composer
    curl -S https://getcomposer.org/installer | php
    chmod a+x composer.phar
    mv composer.phar /usr/local/bin/composer
fi
if ! [ -e .git/hooks ]; then
    echo >&2 "creating a .git/hooks dir to avoid errors"
    mkdir -p .git/hooks
fi

if ! [ -f $SEMAPH ] ; then
    # create the semaphore file with the date in it...
22 23
    date > $SEMAPH

24

25 26 27 28 29
    # run composer to set up dependencies if not already there...
    if ! [ -e vendor/autoload.php ]; then
        echo >&2 "installing dependencies with Composer"
        composer install
    else
30 31
        echo >&2 "vendor dependencies already in place, updating."
        composer update
32
    fi
33 34 35

    #remove semaphore
    rm $SEMAPH
36
else
37 38
    echo >&2 "Looks like another composer is already running. If not, please remove $SEMAPH"
fi
39 40

exec "$@"