Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions components/configurator/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ stage_git_repo() {
}

run_setup_script() {
if [ -n "$SETUP_SCRIPT" ]; then
if [ -f "$SETUP_SCRIPT" ]; then
bash "$SETUP_SCRIPT"
else
echo "Warning: SETUP_SCRIPT defined ('$SETUP_SCRIPT'), but not found."
fi
if [ -d "/init-scripts" ]; then
for script in /init-scripts/*; do
if [ -f "$script" ] && [ -x "$script" ]; then
echo "⚙️ Running setup script: $script"
bash "$script"
fi
done
fi
}

Expand Down
5 changes: 2 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ services:

The Labspace configurator (which clones the repo) provides support to run bootstrap tasks to setup the project workspace, perform environment checks, etc.

To specify a setup script, set the `SETUP_SCRIPT` environment variable with a value to the full path of the script to execute.
To do so, simply add setup scripts into `/init-scripts`.

> [!IMPORTANT]
> If you are defining a script using Compose `configs`, you will need to escape all environment variables as Compose will replace values at config file creation. See the example below for an example.
Expand All @@ -139,12 +139,11 @@ services:
configurator:
environment:
PROJECT_CLONE_URL: https://github.com/dockersamples/labspace-fine-tuning
SETUP_SCRIPT: /scripts/validate-environment.sh
volumes:
- /var/run/docker.sock:/var/run/docker.sock
configs:
- source: validation-script
target: /scripts/validate-environment.sh
target: /init-scripts/validate-environment.sh
configs:
validation-script:
content: |
Expand Down