Skip to content

Commit 7c7ed7f

Browse files
feat(docker): upgrade litestream to v0.5.0 (#3165)
* feat(docker): upgrade litestream to v0.5.0 * feat: update litestream * fix: incorrect arg Co-authored-by: Andrey Cheptsov <54148038+peterschmidt85@users.noreply.github.com> * fix: incorrect arg Co-authored-by: Andrey Cheptsov <54148038+peterschmidt85@users.noreply.github.com> * fix: amd64 was renamed to x86_64 in litestream packages * feat(docker): replace -if-replica-exists with a simple bash script --------- Co-authored-by: Andrey Cheptsov <54148038+peterschmidt85@users.noreply.github.com>
1 parent 2a414fd commit 7c7ed7f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

docker/server/entrypoint.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,21 @@ if [ -n "${GOOGLE_APPLICATION_CREDENTIALS_JSON}" ]; then
77
echo "${GOOGLE_APPLICATION_CREDENTIALS_JSON}" > "${GOOGLE_APPLICATION_CREDENTIALS_DIR}/application_default_credentials.json"
88
fi
99

10+
DB_PATH="${HOME}/.dstack/server/data/sqlite.db"
11+
mkdir -p "$(dirname "$DB_PATH")"
1012
if [[ -z "${LITESTREAM_REPLICA_URL}" ]]; then
11-
dstack server --host 0.0.0.0
13+
exec dstack server --host 0.0.0.0
1214
else
13-
litestream restore -if-replica-exists -o ${HOME}/.dstack/server/data/sqlite.db ${LITESTREAM_REPLICA_URL}
14-
litestream replicate -exec "dstack server --host 0.0.0.0" ${HOME}/.dstack/server/data/sqlite.db ${LITESTREAM_REPLICA_URL}
15+
if [[ ! -f "$DB_PATH" ]]; then
16+
echo "Attempting Litestream restore..."
17+
if ! output=$(litestream restore -o "$DB_PATH" "$LITESTREAM_REPLICA_URL" 2>&1); then
18+
if echo "$output" | grep -qiE "cannot calc restore plan"; then
19+
echo "No replica snapshots found; starting with empty database."
20+
else
21+
echo "$output" >&2
22+
exit 1
23+
fi
24+
fi
25+
fi
26+
exec litestream replicate -exec "dstack server --host 0.0.0.0" "$DB_PATH" "$LITESTREAM_REPLICA_URL"
1527
fi

docker/server/release/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ RUN apt-get update && apt-get install -y \
1313
sqlite3 \
1414
&& rm -rf /var/lib/apt/lists/*
1515

16-
RUN if [ $(uname -m) = "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi && \
17-
curl https://github.com/benbjohnson/litestream/releases/download/v0.3.9/litestream-v0.3.9-linux-$ARCH.deb -O -L && \
18-
dpkg -i litestream-v0.3.9-linux-$ARCH.deb
16+
RUN if [ $(uname -m) = "aarch64" ]; then ARCH="arm64"; else ARCH="x86_64"; fi && \
17+
curl https://github.com/benbjohnson/litestream/releases/download/v0.5.0/litestream-0.5.0-linux-$ARCH.deb -O -L && \
18+
dpkg -i litestream-0.5.0-linux-$ARCH.deb
1919

2020
ADD https://astral.sh/uv/install.sh /uv-installer.sh
2121
RUN sh /uv-installer.sh && rm /uv-installer.sh

docker/server/stgn/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ RUN apt-get update && apt-get install -y \
1111
sqlite3 \
1212
&& rm -rf /var/lib/apt/lists/*
1313

14-
RUN if [ $(uname -m) = "aarch64" ]; then ARCH="arm64"; else ARCH="amd64"; fi && \
15-
curl https://github.com/benbjohnson/litestream/releases/download/v0.3.9/litestream-v0.3.9-linux-$ARCH.deb -O -L && \
16-
dpkg -i litestream-v0.3.9-linux-$ARCH.deb
14+
RUN if [ $(uname -m) = "aarch64" ]; then ARCH="arm64"; else ARCH="x86_64"; fi && \
15+
curl https://github.com/benbjohnson/litestream/releases/download/v0.5.0/litestream-0.5.0-linux-$ARCH.deb -O -L && \
16+
dpkg -i litestream-0.5.0-linux-$ARCH.deb
1717

1818
ADD https://astral.sh/uv/install.sh /uv-installer.sh
1919
RUN sh /uv-installer.sh && rm /uv-installer.sh

0 commit comments

Comments
 (0)