Giter Club home page Giter Club logo

pocketbase-framework-litestream's Introduction

PocketBase & Litestream Example

This repo is a starting spot to use PocketBase as a framework with custom Go code that is backed up and restored via Litestream.

Why does this exist?

I think that PocketBase is an amazing project that can accomplish 99% of what a side-hustle, POC, and even startup needs. However, when using as a framework, we need to be able update code without needing to manually back up the DB file. I wanted to deploy my code in a container to Fly.io, GCP Cloud Run, or AWS App Runner but still utilize the magic of Litestream. This repo allows you to copy/paste the starting files to do just that.

Usage

Prerequisites

You'll need to have an S3-compatible store to connect to. Please see the Litestream Guides to get set up on your preferred object store.

Local Development

Since this is using PocketBase as a Go framework, you can run this locally with go run main.go serve --http "localhost:8080"

You will want to do this to not use your Litestream backed up DB in development.

Deploying to production

Cavitate

You'll notice that in this repo, the Dockerfile has these 3 env variables hard-coded

ENV LITESTREAM_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxx
ENV LITESTREAM_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ENV REPLICA_URL="s3://YOUR_S3_BUCKET_NAME/db"

This is just for ease of deployment to get your container running in the cloud of your choice. You can deploy directly as-is if you want to keep the ENV variables in the Dockerfile.

However, if you want to replace the 3 hardcoded ENV variables in the Dockerfile, you can in a few ways.

  1. For Fly.io you can use the [env] block in the fly.toml. Reference page.
  2. For Google Cloud Run, you can set environment variables for your container See this page on configuration info.
  3. For AWS App runner see this page on configuring ENVs for your continer.

pocketbase-framework-litestream's People

Contributors

tylersustare avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.