laravel / sail

Docker files for running a basic Laravel application.
https://laravel.com/docs/sail
MIT License
1.65k stars 470 forks source link

I cannot create new app with mariadb service #701

Closed lukasinko closed 2 months ago

lukasinko commented 2 months ago

Sail Version

1.0.0

Laravel Version

10.4.1

PHP Version

8.1.4

Operating System

macOS

OS Version

8.1.4

Description

I cannot create new app with mariadb service.

Probably due to recent change to mariadb10/mariadb11 ?

Steps To Reproduce

Using curl -s "https://laravel.build/example-app?with=mariadb" | bash

I get ERROR Invalid services [mariadb]..

Jubeki commented 2 months ago

It should be possible with

curl -s "https://laravel.build/example-app?with=mariadb11" | bash

or

curl -s "https://laravel.build/example-app?with=mariadb10" | bash

Is this documented somewhere? (If yes, we should probably add an alias)

lukasinko commented 2 months ago
curl -s "https://laravel.build/test-app?with=mariadb11" | bash                                                                                                                                                                  
bash: line 1: syntax error near unexpected token `('
bash: line 1: `Invalid service name. Please provide one or more of the supported services (mysql, pgsql, mariadb, redis, memcached, meilisearch, typesense, minio, mailpit, selenium, soketi) or "none".'
Jubeki commented 2 months ago

@lukasinko I created a PR on the Sail Server Side, which should fix the problem: https://github.com/laravel/sail-server/pull/23

lukasinko commented 2 months ago

@Jubeki I don't think it is solved, now there is and error using: curl -s "https://laravel.build/jobs-app?with=mariadb" | bash

error in middle of lines:

➜ ./vendor/bin/sail artisan migrate

no such service: mariadb11
[+] Building 172.4s (17/17) FINISHED

no such service: mariadb11 ?

Jubeki commented 2 months ago

@lukasinko I can't explain this no such service: mariadb11 but it seems to be installing the mariadb service correctly in the docker-compose.yml.

ikhusus commented 1 month ago

@lukasinko I can't explain this no such service: mariadb11 but it seems to be installing the mariadb service correctly in the docker-compose.yml.

Hello @Jubeki , please check the generated script. I think this part need to be fixed:

$ curl -s -o "example-app.sh" "https://laravel.build/example-app?with=mariadb"
$ cat example-app.sh
# ... skipped ...
docker run --rm \
    --pull=always \
    -v "$(pwd)":/opt \
    -w /opt \
    laravelsail/php83-composer:latest \
    bash -c "laravel new example-app --no-interaction && cd example-app && php ./artisan sail:install --with=mariadb11 "

cd example-app

# Allow build with no additional services..
if [ "mariadb11" == "none" ]; then
    ./vendor/bin/sail build
else
    ./vendor/bin/sail pull mariadb11  # <=== THIS PART NEED TO BE FIXED ?
    ./vendor/bin/sail build
fi

Pay attention to the line:

./vendor/bin/sail pull mariadb11

I think it should be:

./vendor/bin/sail pull mariadb

Because the generated docker-compose.yml is:

$ cat example-app/docker-compose.yml
services:
    laravel.test:
        build:
#... skipped ...
        depends_on:
            - mariadb
    mariadb:  # <===== THIS IS THE CORRESPONDING SERVICE NAME :) NOT 'mariadb11'
        image: 'mariadb:11'
#... skipped ...

Please note the syntax for docker compose pull is (I am using Podman. But it should be the same in Docker) :

$ example-app/vendor/bin/sail pull --help
#...skipped...
usage: podman-compose pull [-h] [--force-local] [services ...]

positional arguments:
  services       services to pull

options:
  -h, --help     show this help message and exit
  --force-local  Also pull unprefixed images for services which have a build section

$ podman-compose pull --help
usage: podman-compose pull [-h] [--force-local] [services ...]

positional arguments:
  services       services to pull

options:
  -h, --help     show this help message and exit
  --force-local  Also pull unprefixed images for services which have a build section

So, it needs Service Name (NOT Repo Name) corresponding to the docker-compose.yml.

@lukasinko, please reopen this issue :). @taylorotwell, I think this one is crucial :).

Thank You.

Jubeki commented 1 month ago

At this point I am not sure, if all the complex replacements due to the different mariadb versions is worth it, or if it should be reverted to only a single mariadb version (like with mysql 8 where there is no mysql 5.7).

@driesvints what is your take on this? Should I send in a PR fixing the Sail-Server-Script or reverting the mariadb changes and only allow a single MariaDB version (probably in this case the newest one 11).

driesvints commented 1 month ago

yes let's go for mariadb 11 only