Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #113 from ar-io/litestream
Browse files Browse the repository at this point in the history
chore(litestream): add docker builds for litestream
  • Loading branch information
dtfiedler authored May 8, 2024
2 parents 1c86ed6 + 227389b commit 905ca3b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/litestream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Litestream

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'litestream/**'
jobs:
push:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
checks: write
packages: write
steps:
- uses: actions/checkout@v4
# Build and push container image to GCR (only on main branch)
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push container image to GitHub Container Registry
uses: docker/build-push-action@v4
with:
push: true
context: litestream
tags: |
ghcr.io/ar-io/arns-litestream:latest
ghcr.io/ar-io/arns-litestream:${{ github.sha }}
20 changes: 20 additions & 0 deletions litestream/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Start with a standard Ubuntu base image
FROM ubuntu:20.04 as builder

# Install curl and other necessary tools
RUN apt-get update && apt-get install -y curl

# Download and install ytt
RUN curl -L https://github.com/vmware-tanzu/carvel-ytt/releases/download/v0.44.1/ytt-linux-amd64 > /usr/local/bin/ytt \
&& chmod 755 /usr/local/bin/ytt

FROM litestream/litestream:latest

COPY --from=builder /usr/local/bin/ytt /usr/local/bin/ytt

COPY litestream.template.yaml .
COPY docker-entrypoint.sh .

RUN chmod 755 /docker-entrypoint.sh

ENTRYPOINT [ "./docker-entrypoint.sh" ]
7 changes: 7 additions & 0 deletions litestream/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
set -e

# Update env vars
ytt --data-values-env TVAL -f /litestream.template.yaml > /litestream.yml

/usr/local/bin/litestream replicate -config /litestream.yml
9 changes: 9 additions & 0 deletions litestream/litestream.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#@ load("@ytt:data", "data")

dbs:
- path: #@ data.values.LOCAL_DB_PATH + "/state.db"
replicas:
- url: #@ data.values.S3_BUCKET_PATH
- path: #@ data.values.LOCAL_DB_PATH + "/contract.db"
replicas:
- url: #@ data.values.S3_BUCKET_PATH

0 comments on commit 905ca3b

Please sign in to comment.