-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-entrypoint
More file actions
executable file
·52 lines (39 loc) · 1.14 KB
/
Copy pathdocker-entrypoint
File metadata and controls
executable file
·52 lines (39 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# Exit on first failing command.
set -e
# Exit on unset variable.
set -u
# Fail when piped commands fail.
set -o pipefail
APP_ARGS="$*"
readonly APP_ARGS
is_litestream_enabled() {
local IS_ENABLED='false'
if [[ -n "${LITESTREAM_BUCKET:-}" ]]; then
IS_ENABLED='true';
fi
echo "${IS_ENABLED}"
}
IS_LITESTREAM_ENABLED="$(is_litestream_enabled)"
readonly IS_LITESTREAM_ENABLED
# Echo commands to stdout.
set -x
APP_LAUNCH_CMD="/app/screenjournal -db ${DB_PATH} ${APP_ARGS}"
if [[ "${IS_LITESTREAM_ENABLED}" == 'true' ]]; then
/app/litestream version
echo "LITESTREAM_BUCKET=${LITESTREAM_BUCKET}"
echo "LITESTREAM_ENDPOINT=${LITESTREAM_ENDPOINT:-}"
if [[ -f "$DB_PATH" ]]; then
echo "Existing database is $(stat -c %s "${DB_PATH}") bytes"
else
echo "No existing database found"
# Restore database from remote storage.
mkdir -p "$(dirname "${DB_PATH}")"
/app/litestream restore -if-replica-exists "${DB_PATH}"
fi
# Let Litestream start screenjournal as a child process
/app/litestream replicate -exec "$APP_LAUNCH_CMD"
else
echo "Starting without litestream"
eval "${APP_LAUNCH_CMD}"
fi