-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cvm: Add pre_launch_script in app-compose
- Loading branch information
Showing
4 changed files
with
85 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
#!/bin/sh | ||
tdxctl notify-host -e "boot.progress" -d "starting containers" || true | ||
#!/bin/bash | ||
|
||
docker compose up --remove-orphans -d || true | ||
chmod +x /usr/bin/containerd-shim-runc-v2 | ||
systemctl restart docker | ||
if [ $(jq 'has("pre_launch_script")' app-compose.json) == true ]; then | ||
echo "Running pre-launch script" | ||
tdxctl notify-host -e "boot.progress" -d "pre-launch" || true | ||
source <(jq -r '.pre_launch_script' app-compose.json) | ||
fi | ||
|
||
RUNNER=$(jq -r '.runner' app-compose.json) | ||
case "$RUNNER" in | ||
"docker-compose") | ||
echo "Starting containers" | ||
tdxctl notify-host -e "boot.progress" -d "starting containers" || true | ||
if ! [ -f docker-compose.yaml ]; then | ||
jq -r '.docker_compose_file' app-compose.json >docker-compose.yaml | ||
fi | ||
docker compose up --remove-orphans -d || true | ||
chmod +x /usr/bin/containerd-shim-runc-v2 | ||
systemctl restart docker | ||
|
||
if ! docker compose up --remove-orphans -d; then | ||
tdxctl notify-host -e "boot.error" -d "failed to start containers" | ||
if ! docker compose up --remove-orphans -d; then | ||
tdxctl notify-host -e "boot.error" -d "failed to start containers" | ||
exit 1 | ||
fi | ||
;; | ||
"bash") | ||
chmod +x /usr/bin/containerd-shim-runc-v2 | ||
echo "Running main script" | ||
tdxctl notify-host -e "boot.progress" -d "running main script" || true | ||
jq -r '.bash_script' app-compose.json | bash | ||
;; | ||
*) | ||
echo "ERROR: unsupported runner: $RUNNER" >&2 | ||
tdxctl notify-host -e "boot.error" -d "unsupported runner: $RUNNER" | ||
exit 1 | ||
fi | ||
;; | ||
esac | ||
|
||
tdxctl notify-host -e "boot.progress" -d "done" || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters