Skip to content

Commit

Permalink
Create Literiver, a mass-sqlite backup tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvolp12 committed Nov 7, 2023
1 parent 3f7c1d3 commit 68c42f2
Show file tree
Hide file tree
Showing 9 changed files with 1,295 additions and 28 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/container-literiver-ghcr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: container-bigsky-ghcr
on: [push]
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}

# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
container-bigsky-ghcr:
if: github.repository == 'bluesky-social/indigo'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ env.PASSWORD }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,enable=true,priority=100,prefix=literiver:,suffix=,format=long
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
file: ./cmd/literiver/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,13 @@ run-scylla:
stop-scylla:
@echo "==> Stopping test instance of Scylla $(SCYLLA_VERSION)"
@docker stop scylla

.PHONY: build-literiver
build-literiver:
@echo "==> Building literiver"
go build -extldflags '-static'" -tags osusergo,netgo,sqlite_omit_load_extension ./cmd/literiver

.PHONY: build-literiver-image
build-literiver-image: build-literiver
@echo "==> Building literiver image"
docker build -t literiver -f cmd/literiver/Dockerfile .
33 changes: 33 additions & 0 deletions cmd/literiver/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
### Compile stage
FROM golang:1.21-alpine3.18 AS build-env
RUN apk add --no-cache build-base make git

ADD . /dockerbuild
WORKDIR /dockerbuild

# timezone data for alpine builds
ENV GOEXPERIMENT=loopvar
RUN GIT_VERSION=$(git describe --tags --long --always) && \
go build -tags timetzdata -o /literiver ./cmd/literiver

### Run stage
FROM alpine:3.18

RUN apk add --no-cache --update dumb-init ca-certificates
ENTRYPOINT ["dumb-init", "--"]

WORKDIR /
RUN mkdir -p data/literiver
COPY --from=build-env /literiver /

# small things to make golang binaries work well under alpine
ENV GODEBUG=netdns=go
ENV TZ=Etc/UTC

EXPOSE 9032

CMD ["/literiver"]

LABEL org.opencontainers.image.source=https://github.com/bluesky-social/literiver
LABEL org.opencontainers.image.description="Litestream-based Mass SQLite Replicator"
LABEL org.opencontainers.image.licenses=MIT
Loading

0 comments on commit 68c42f2

Please sign in to comment.