Skip to content
/ tiny-stack Public template
forked from Sh4yy/tiny-stack

A simple and tiny stack for building web applications using Astro, SQLite, and Litestream.

License

Notifications You must be signed in to change notification settings

ilanc/tiny-stack

 
 

Repository files navigation

Tiny Stack

thumbnail

A simple and tiny stack for building web applications using Astro, SQLite, and Litestream.

Tutorial

Here is a thorough tutorial on the Tiny Stack.

Quick Start

  1. Build the Docker image
docker build -t tiny-stack .
  1. Set environment variables

Copy/paste the contents of .env.example into a new .env file and fill in the values, then run:

source .env

OR export individual variables:

# https://litestream.io/getting-started/
docker run -p 9000:9000 -p 9001:9001 minio/minio server /data --console-address ":9001"
xdg-open http://localhost:9001/ &
# Buckets > Create Bucket > Save: bucket name = mybkt
# export REPLICA_URL=https://<account_id>.r2.cloudflarestorage.com
# litestream replicate fruits.db s3://mybkt.localhost:9000/fruits.db
export REPLICA_URL=s3://mybkt.localhost:9000/fruits.db
export LITESTREAM_ACCESS_KEY_ID=minioadmin
export LITESTREAM_SECRET_ACCESS_KEY=minioadmin

# install litestream & sqllite in host
wget https://github.com/benbjohnson/litestream/releases/download/v0.3.13/litestream-v0.3.13-linux-amd64.deb
sudo dpkg -i litestream-v0.3.13-linux-amd64.deb
rm !$
sudo apt install sqlite3

# create fruits.db
sqlite3 fruits.db
CREATE TABLE fruits (name TEXT, color TEXT);
INSERT INTO fruits (name, color) VALUES ('apple', 'red');
INSERT INTO fruits (name, color) VALUES ('banana', 'yellow');

# replicate it to minio s3
litestream replicate fruits.db s3://mybkt.localhost:9000/fruits.db

docker run   -p 4321:4321   -e REPLICA_URL   -e LITESTREAM_ACCESS_KEY_ID   -e LITESTREAM_SECRET_ACCESS_KEY   -v $(pwd)/data:/data -it --entrypoint=/bin/sh   tiny-stack
  1. Run the Docker image
docker run \
  -p 4321:4321 \
  -e REPLICA_URL \
  -e LITESTREAM_ACCESS_KEY_ID \
  -e LITESTREAM_SECRET_ACCESS_KEY \
  -v $(pwd)/data:/data \
  tiny-stack

The same command as a single line in case slashes are causing issues:

docker run -p 4321:4321 -e REPLICA_URL -e LITESTREAM_ACCESS_KEY_ID -e LITESTREAM_SECRET_ACCESS_KEY -v $(pwd)/data:/data tiny-stack
  1. Head to http://localhost:4321

About

A simple and tiny stack for building web applications using Astro, SQLite, and Litestream.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Astro 46.4%
  • TypeScript 18.3%
  • Dockerfile 17.0%
  • JavaScript 10.7%
  • Shell 7.6%