dcp 1.41 KB
Newer Older
Nicolas Widart's avatar
Nicolas Widart committed
1 2 3 4 5 6 7 8 9
#!/bin/bash

COMPOSE="docker-compose"

if [ $# -gt 0 ]; then
    if [ "$1" == "up" ]; then
        $COMPOSE up -d
    elif [ "$1" == "reload" ] || [ "$1" == "restart" ] || [ "$1" == "rs" ] || [ "$1" == "rl" ]; then
        $COMPOSE down && $COMPOSE up -d
10
    elif [ "$1" == "artisan" ] || [ "$1" == "art" ] || [ "$1" == "a" ]; then
Nicolas Widart's avatar
Nicolas Widart committed
11 12 13
        shift 1
        EXEC_CMD="cd /var/www/html && php artisan $@"
        $COMPOSE exec app bash -c "$EXEC_CMD"
14 15 16 17 18 19 20 21
    elif [ "$1" == "bin/console" ]; then
        shift 1
        EXEC_CMD="cd /var/www/html && php bin/console $@"
        $COMPOSE exec app bash -c "$EXEC_CMD"
    elif [ "$1" == "app/console" ]; then
        shift 1
        EXEC_CMD="cd /var/www/html && php app/console $@"
        $COMPOSE exec app bash -c "$EXEC_CMD"
Nicolas Widart's avatar
Nicolas Widart committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
    elif [ "$1" == "test" ]; then
        shift 1
        $COMPOSE run --rm -w /var/www/html app ./vendor/bin/phpunit $@
    elif [ "$1" == "t" ]; then
        shift 1
        $COMPOSE exec app bash -c "cd /var/www/html && ./vendor/bin/phpunit $@"
    elif [ "$1" == "composer" ]; then
        shift 1
        EXEC_CMD="cd /var/www/html && composer $@"
        $COMPOSE exec app bash -c "$EXEC_CMD"
    elif [ "$1" == "yarn" ]; then
        shift 1
        $COMPOSE run --rm -w /var/www/html node yarn $@
    elif [ "$1" == "npm" ]; then
        shift 1
        $COMPOSE run --rm -w /var/www/html node npm $@
    else
        $COMPOSE $@
    fi
else
    $COMPOSE ps
fi