-
Notifications
You must be signed in to change notification settings - Fork 3
Description
The command allows wrapping /bin/bash per project to selectively running commands in containers
It should be included in regular output, like others. e.g.
source dotenv/load.sh
./scripts/util/exec.sh - <<SCRIPT
> echo Working dir: && pwd
> SCRIPT
Usage examples:
- phapp exec ls → always run in app environment, it should have the correct working dir
- phapp exec → opens shell in main container!
Without any argument, it should default to /bin/bash - thus open a new shell.
Executing manifest commands needs to be reworked, so that the API function includes the exec wrapper always.
However, we do not want to run the exec wrapper for "build" by default. But that should be configurable per project. To achieve that, we provide the name of the command to be executed in the variable "PHAPP_COMMAND". This new variable should be provided to all commands and be documented in the README as "A variable that is set to the name of the command executed if some command script of the phapp manifest is currently executed."
Then in the project templates, we control the exec command via dotenv variables:
COMMAND_EXEC_PREFIX: "docker compose exec web"
and apply them conditionally in the manifest:
setup: ...
exec:
# Default to running build commands on the host.
if $PHAPP_COMMAND = 'build' ; then
COMMAND_EXEC_PREFIX=''
fi
$COMMAND_EXEC_PREFIX $@