vscode-laravel-artisan
vscode-laravel-artisan copied to clipboard
Cannot run in Docker
I am unable to run the commands against Docker, because the commands automatically cd
into the current artisanRoot
directory before running the artisan.docker.command
.
Code Output:
[CMD] php artisan route:list
[ERR] Command failed: cd /home/user/Code/laravel/laravel/ && docker-compose --user laradock exec workspace && cd /var/www/laravel/laravel php artisan route:list
Wondering if the docker logic could branch a bit more, so that:
-
"artisan.docker.root-path": "cd /path/to/docker-compose/repository"
could be set to know where on the local machine theartisan.docker.command
should be run from -
"artisan.docker.path-map": { "/var/www": "/home/user/Code" }
can be set to inform the command what directory in the container to run the command against.
let localArtisanRoot = artisanRoot
let dockerPathMap = config.get('docker.path-map', null)
let dockerRoot = config.get('docker.root-path', null)
if (dockerEnabled) {
// if user did not supply a custom dockerRoot, assume we should use the local path to the current artisan
if(!dockerRoot) {
dockerRoot = localArtisanRoot
}
// if user supplied a path map, replace in the path for docker
if(dockerPathMap) {
Object.entries(dockerPathMap).forEach(([replace, find]) => artisanRoot.replace(find, replace ))
}
command = `php artisan ${command}`
cmd = `cd ${dockerRoot} && ${dockerCommand} "cd ${artisanRoot} ${command}"`
}
In this example, cmd
will evaluate to:
cd /path/to/docker-compose/repository && docker-compose exec workspace bash -c "cd /var/www/project && php artisan route:list"
I've a problem too. When I try to run my docker command with this wxtension I get the error: the input device is not a TTY
[ERR] Command failed: cd /home/victor/projects/api/ && docker-compose exec php php artisan route:list
the input device is not a TTY
But if I just copy the command of this output and run into my terminal, works properly: cd /home/victor/projects/api/ && docker-compose exec php php artisan route:list
Do you have any ideia?
Same issue here simple solution is to add the option -T
to exec
but with this option i have no more output inside the OUTPUT panel
Vscode settings => Artisan > Docker:Command: docker-compose exec -T <app>
[CMD] php artisan key:generate --show [CMD] php artisan migrate [ERR] Command failed: cd /home/greefine/Projects/Blackfoot/airbnb-server-v2/ && docker-compose exec -T app php artisan migrate
Yes! The -T option really solves the problem!
Also, the plugin assumes artisan is already enabled in $PATH. Allowing to customize the command could be very helpful here.
Marking issue as stale since there has'nt been any activity recently.
Following this example below, I hope it helps others:
docker exec container_name php artisan migrate --database=api
status=$?
if [ $status -ne 0 ]; then
echo "Erro: O comando de migração falhou com código de saída $status"
exit 1
fi