Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability for custom startup script #55

Merged
merged 8 commits into from
Jun 28, 2018
6 changes: 6 additions & 0 deletions 5.6/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www
echo-debug "Preliminary initialization completed"
touch /var/run/cli

if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then
echo-debug "Running Custom Startup Script..."
${PROJECT_ROOT}/.docksal/services/cli/startup.sh
echo-debug "Custom Startup Script Complete..."
fi

# Execute passed CMD arguments
echo-debug "Executing the requested command..."
# Service mode (run as root)
Expand Down
6 changes: 6 additions & 0 deletions 7.0/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www
echo-debug "Preliminary initialization completed"
touch /var/run/cli

if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then
echo-debug "Running Custom Startup Script..."
${PROJECT_ROOT}/.docksal/services/cli/startup.sh
echo-debug "Custom Startup Script Complete..."
fi

# Execute passed CMD arguments
echo-debug "Executing the requested command..."
# Service mode (run as root)
Expand Down
6 changes: 6 additions & 0 deletions 7.1/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www
echo-debug "Preliminary initialization completed"
touch /var/run/cli

if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then
echo-debug "Running Custom Startup Script..."
${PROJECT_ROOT}/.docksal/services/cli/startup.sh
echo-debug "Custom Startup Script Complete..."
fi

# Execute passed CMD arguments
echo-debug "Executing the requested command..."
# Service mode (run as root)
Expand Down
6 changes: 6 additions & 0 deletions 7.2/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ chown "${HOST_UID-:1000}:${HOST_GID:-1000}" /var/www
echo-debug "Preliminary initialization completed"
touch /var/run/cli

if [[ -x ${PROJECT_ROOT}/.docksal/services/cli/startup.sh ]]; then
echo-debug "Running Custom Startup Script..."
${PROJECT_ROOT}/.docksal/services/cli/startup.sh
echo-debug "Custom Startup Script Complete..."
fi

# Execute passed CMD arguments
echo-debug "Executing the requested command..."
# Service mode (run as root)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ cli

See [docs](https://docs.docksal.io/en/master/tools/xdebug) on using Xdebug for web and cli PHP debugging.

## Customizing Startup

To run a custom startup script anytime the `cli` container has started create a `startup.sh` file within the
`.docksal/services/cli` directory. Additionally, make sure that the file is executable as well so that the container
does not run into issues when attempting to execute the file.

## Secrets and integrations

Expand Down
3 changes: 3 additions & 0 deletions tests/.docksal/services/cli/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "I ran properly" > /tmp/test-startup.txt
12 changes: 12 additions & 0 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ _healthcheck_wait ()
rm -f .docksal/docksal-local.env
}

@test "Check Custom Startup Script Works" {
[[ $SKIP == 1 ]] && skip

cd ../tests
echo "CLI_IMAGE=\"${IMAGE}\"" > .docksal/docksal-local.env
fin reset -f

run fin exec -T 'cat /tmp/test-startup.txt'
[[ ${status} == 0 ]] &&
[[ "${output}" =~ "I ran properly" ]]
}

@test "Check Platform.sh Integration" {
[[ $SKIP == 1 ]] && skip

Expand Down