Skip to content
Snippets Groups Projects
Commit 40b21a0b authored by ale's avatar ale
Browse files

Install litestream in the container image

parent ea70e62a
No related branches found
No related tags found
1 merge request!29Add Litestream
Pipeline #24157 passed
...@@ -4,6 +4,12 @@ RUN cd /src && \ ...@@ -4,6 +4,12 @@ RUN cd /src && \
go build -ldflags="-extldflags=-static" -tags "sqlite_omit_load_extension netgo" -o tabacco ./cmd/tabacco && \ go build -ldflags="-extldflags=-static" -tags "sqlite_omit_load_extension netgo" -o tabacco ./cmd/tabacco && \
strip tabacco strip tabacco
FROM debian:stable-slim AS litestream-dl
ENV LITESTREAM_VERSION=0.3.6
ADD https://github.com/benbjohnson/litestream/releases/download/v${LITESTREAM_VERSION}/litestream-v${LITESTREAM_VERSION}-linux-amd64-static.tar.gz /tmp/
RUN tar -C /usr/bin -xzv -f /tmp/litestream-v${LITESTREAM_VERSION}-linux-amd64-static.tar.gz && chmod 755 /usr/bin/litestream
FROM registry.git.autistici.org/ai3/docker/s6-base:master FROM registry.git.autistici.org/ai3/docker/s6-base:master
COPY --from=build /src/tabacco /usr/bin/tabacco COPY --from=build /src/tabacco /usr/bin/tabacco
COPY --from=litestream-dl /usr/bin/litestream /usr/bin/litestream
COPY metadb/docker/etc/ /etc/ COPY metadb/docker/etc/ /etc/
...@@ -5,6 +5,10 @@ if [ -n "${LITESTREAM_URL}" ]; then ...@@ -5,6 +5,10 @@ if [ -n "${LITESTREAM_URL}" ]; then
# Query the tabacco configuration to obtain the database path. # Query the tabacco configuration to obtain the database path.
db_path=$(tabacco metadb-config --config=${TABACCO_CONF:-/etc/tabacco/metadb.yml} db-uri) db_path=$(tabacco metadb-config --config=${TABACCO_CONF:-/etc/tabacco/metadb.yml} db-uri)
if [ -z "${db_path}" ]; then
echo "Error reading db-uri from tabacco" >&2
exit 1
fi
if [ ! -e "${db_path}" ]; then if [ ! -e "${db_path}" ]; then
echo "Database is missing, attempting restore..." >&2 echo "Database is missing, attempting restore..." >&2
......
#!/bin/sh #!/bin/sh
db_path=$(tabacco metadb-config --config=${TABACCO_CONF:-/etc/tabacco/metadb.yml} db-uri) db_path=$(tabacco metadb-config --config=${TABACCO_CONF:-/etc/tabacco/metadb.yml} db-uri)
if [ -z "${db_path}" ]; then
echo "Error reading db-uri from tabacco" >&2
sleep 3
exit 1
fi
exec litestream replicate "${db_path}" "${LITESTREAM_URL}" exec litestream replicate "${db_path}" "${LITESTREAM_URL}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment