forked from HumanSignal/label-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy data to static volume during docker-compose startup (HumanSignal…
- Loading branch information
Showing
8 changed files
with
68 additions
and
27 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
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
9 changes: 3 additions & 6 deletions
9
deploy/wait-for-postgres.sh → ...cker-entrypoint.d/10-wait-for-postgres.sh
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,9 @@ | ||
#!/bin/sh | ||
# wait-for-postgres.sh | ||
|
||
set -e | ||
|
||
|
||
echo >&3 "=> Waiting for postgres..." | ||
until PGPASSWORD=$POSTGRE_PASSWORD psql -h "$POSTGRE_HOST" -p $POSTGRE_PORT -U "$POSTGRE_USER" -c '\q'; do | ||
>&2 echo "Postgres is unavailable - sleeping" | ||
echo >&3 "==> Postgres is unavailable - sleeping..." | ||
sleep 1 | ||
done | ||
|
||
>&2 echo "Postgres is up - executing command" | ||
echo >&3 "=> Postgres is up." |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo >&3 "=> Do database migrations..." | ||
cat /label-studio/label_studio/manage.py | ||
python3 /label-studio/label_studio/manage.py migrate >&3 | ||
echo >&3 "=> Migrations completed." |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
DATA_SOURCE="/label-studio/label_studio" | ||
DATA_TARGET="/label-studio/static_volume" | ||
|
||
if [ -z "${LABEL_STUDIO_COPY_STATIC_DATA:-}" ]; then | ||
echo >&3 "=> Skipping copy data." | ||
else | ||
echo >&3 "=> Copy static data to a shared folder..." | ||
if [ -d $DATA_SOURCE ] && [ -d $DATA_TARGET ]; then | ||
rm -rf $DATA_TARGET/* || true | ||
cp -r $DATA_SOURCE/* $DATA_TARGET/ | ||
fi | ||
echo >&3 "=> Successfully copied." | ||
fi |
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,17 +1,32 @@ | ||
#!/usr/bin/env bash | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# if wait-for-postgres script is specified, we sleep in the loop until Postgre is up | ||
if [[ "$1" = "./deploy/wait-for-postgres.sh" ]]; then | ||
# ./deploy/wait-for-postgres.sh db | ||
$1 | ||
shift 1 | ||
fi | ||
# Redirect all scripts output + leaving stdout to container payload. | ||
exec 3>&1 | ||
|
||
echo "=> Do database migrations..." | ||
python3 label_studio/manage.py migrate | ||
if [ "$1" = "label-studio" ]; then | ||
if /usr/bin/find "/label-studio/deploy/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then | ||
echo >&3 "$0: Looking for init scripts in /label-studio/deploy/docker-entrypoint.d/" | ||
find "/label-studio/deploy/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do | ||
case "$f" in | ||
*.sh) | ||
if [ -x "$f" ]; then | ||
echo >&3 "$0: Launching $f"; | ||
"$f" | ||
else | ||
# warn on shell scripts without exec bit | ||
echo >&3 "$0: Ignoring $f, not executable"; | ||
fi | ||
;; | ||
*) echo >&3 "$0: Ignoring $f";; | ||
esac | ||
done | ||
|
||
echo "=> Run $@..." | ||
exec "$@" | ||
echo >&3 "$0: Configuration complete; ready for start up" | ||
else | ||
echo >&3 "$0: No init scripts found in /label-studio/deploy/docker-entrypoint.d/, skipping configuration" | ||
fi | ||
fi | ||
|
||
exec "$@" |
This file was deleted.
Oops, something went wrong.
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