File tree Expand file tree Collapse file tree 3 files changed +21
-9
lines changed
Expand file tree Collapse file tree 3 files changed +21
-9
lines changed Original file line number Diff line number Diff 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"
88fi
99
10+ DB_PATH=" ${HOME} /.dstack/server/data/sqlite.db"
11+ mkdir -p " $( dirname " $DB_PATH " ) "
1012if [[ -z " ${LITESTREAM_REPLICA_URL} " ]]; then
11- dstack server --host 0.0.0.0
13+ exec dstack server --host 0.0.0.0
1214else
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 "
1527fi
Original file line number Diff line number Diff 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
2020ADD https://astral.sh/uv/install.sh /uv-installer.sh
2121RUN sh /uv-installer.sh && rm /uv-installer.sh
Original file line number Diff line number Diff 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
1818ADD https://astral.sh/uv/install.sh /uv-installer.sh
1919RUN sh /uv-installer.sh && rm /uv-installer.sh
You can’t perform that action at this time.
0 commit comments