Skip to content

Instantly share code, notes, and snippets.

@wffranco
Last active July 19, 2024 21:01
Show Gist options
  • Save wffranco/e6974f80ed4703ff45c540637a2c66a5 to your computer and use it in GitHub Desktop.
Save wffranco/e6974f80ed4703ff45c540637a2c66a5 to your computer and use it in GitHub Desktop.

Revisions

  1. wffranco revised this gist Jul 19, 2024. No changes.
  2. wffranco revised this gist Jul 19, 2024. 1 changed file with 20 additions and 11 deletions.
    31 changes: 20 additions & 11 deletions sail
    Original file line number Diff line number Diff line change
    @@ -2,17 +2,26 @@

    cd "$(dirname "${BASH_SOURCE[0]}")"

    #if the command is called with `init` param, or `vendor` folder is missing
    if [ "$1" = "init" ] || [ ! -d vendor ]; then
    #run laravel sail container to run `composer install`
    docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs
    if [ ! -e ./vendor ]; then
    docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v "$(pwd):/var/www/html" \
    -w /var/www/html \
    laravelsail/php83-composer:latest \
    composer install --ignore-platform-reqs
    fi

    if [ "$1" != "init" ]; then
    ./vendor/bin/sail $@
    if [ ! -f .env ]; then
    cp .env.example .env
    ./sail artisan key:generate
    fi

    # if the first argument is "in:*", use it as service name, setting the APP_SERVICE environment variable
    # example of usage: sail in:mysql mysql -u root -p
    # useful if you use extra or non-default services in your docker-compose.yml
    if [[ $1 == in:* ]]; then
    export APP_SERVICE=${1:3}
    shift
    fi

    ./vendor/bin/sail $@
  3. wffranco created this gist May 22, 2023.
    18 changes: 18 additions & 0 deletions sail
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/usr/bin/env bash

    cd "$(dirname "${BASH_SOURCE[0]}")"

    #if the command is called with `init` param, or `vendor` folder is missing
    if [ "$1" = "init" ] || [ ! -d vendor ]; then
    #run laravel sail container to run `composer install`
    docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs
    fi

    if [ "$1" != "init" ]; then
    ./vendor/bin/sail $@
    fi