JoeCode
Litestream, Dockerfile, and Fly.io
Jan 13, 2025I used the following articles to piece together deploying a Sinatra, SQLite, and Litestream setup on Fly.io:
- Gray Matter - LITE-IST stack
- Michael Lynch - How Litestream eliminated my database server
- Tobias Lütke - Dockerfile
- Fly.io - I’m all-in on server-side SQLite
- Litestream - Docker guide
Litestream specific bits of my Fly.io Dockerfile:
...
# Litestream install
ADD https://github.com/benbjohnson/litestream/releases/download/v0.3.13/litestream-v0.3.13-linux-amd64.tar.gz /tmp/litestream.tar.gz
RUN tar -C /usr/local/bin -xzf /tmp/litestream.tar.gz
...
# Verify litestream
# Restore the database
# Setup database replication
# Start the web application server
EXPOSE 8080
CMD \
litestream version; \
litestream restore -if-db-not-exists -if-replica-exists -o data/app.db "s3://BUCKET/FOLDER"; \
litestream replicate -exec "bundle exec rackup --host 0.0.0.0 --port 8080" data/app.db "s3://BUCKET/FOLDER"