dcp 1.41 KB
#!/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
    elif [ "$1" == "artisan" ] || [ "$1" == "art" ] || [ "$1" == "a" ]; then
        shift 1
        EXEC_CMD="cd /var/www/html && php artisan $@"
        $COMPOSE exec app bash -c "$EXEC_CMD"
    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"
    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