Giter Site home page Giter Site logo

goatcounter-on-fly's Introduction

Goatcounter on fly.io

This repository contains a template for setting up and running goatcounter on fly.io, including Litestream backing up our SQLite database to a S3 (compatible) bucket. This setup runs great on the fly.io free tier (1 shared CPU, 256 MB of memory, 1 GB of disk), at least for a small website. You can also make use of Backblaze B2's free tier1 to store your backups.

One important thing to note is that this is a single node setup using local volumes, so in case the host running our container dies we might not be automagically migrated to a new host. However, our data is reasonably safe due to Litestream backups, so we should not lose more than a few minutes of data (at most).

PRs are always welcome!

Prerequisites

Usage

  1. Clone or fork this repository.

    git clone https://github.com/oscarcarlsson/goatcounter-on-fly.git && cd goatcounter-on-fly
  2. Run the command below and answer the questions - you don't need Redis nor Postgres! This will generate a fly.toml but won't try to launch anything yet. Make sure you change the name for the application as well.

    flyctl launch --no-deploy --memory 256 --name CHANGEME
    

    If you want, you can always specify the region to launch the VM in. You can list all regions by running: flyctl platform regions

  3. Create a volume for the database, change to your preferred region:

    flyctl volumes create goatcounter_data --region CHANGEME --size 1
  4. Open fly.toml and add the following to the env section:

    [env]
      # Change these!
      GOATCOUNTER_DOMAIN = 'goatcounter.example.com'
      GOATCOUNTER_EMAIL = '[email protected]'
    
      # Change these for your S3 provider!
      LITESTREAM_REPLICA_ENDPOINT = ''
      LITESTREAM_REPLICA_BUCKET = ''
    
      # These can be blank
      GOATCOUNTER_SMTP = ''
      GOATCOUNTER_DEBUG = ''
    
      # Don't change these
      GOATCOUNTER_LISTEN = '0.0.0.0:8080'
      GOATCOUNTER_DB = '/data/goatcounter.sqlite3'
      LITESTREAM_REPLICA_PATH = 'goatcounter_replica.sqlite3'

    Also make sure that the mount section looks something like this:

    [[mounts]]
    source = 'goatcounter_data'
    destination = '/data'
    processes = ['app']
  5. Nearly done! Now, create secrets for your secrets:

    flyctl secrets set GOATCOUNTER_PASSWORD="changeme" LITESTREAM_ACCESS_KEY_ID="changeme" LITESTREAM_SECRET_ACCESS_KEY="changeme"

    The secret called GOATCOUNTER_PASSWORD will be the initial password for the admin account.

  6. Now, try to deploy the application!

Credits

This is heavily inspired by fspoettel/linkding-on-fly.

Footnotes

  1. Their free tier is 10GB free, then $0.005 per GB, which is plenty โ†ฉ

goatcounter-on-fly's People

Contributors

oscarcarlsson avatar

Watchers

 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.