make firebase-emulatorexport FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9099
export FIREBASE_IDENTITY_BASE_URL=http://localhost:9099/identitytoolkit.googleapis.com/v1/accounts
export FIREBASE_TOKEN_BASE_URL=http://localhost:9099/securetoken.googleapis.com/v1/token
SERVER_PORT=9090 DEBUG=1 go run ./cmd/serverSwagger documentation is available at http://localhost:9090/docs
To populate the database with initial data for local development:
DATABASE_PATH=data.db go run ./cmd/seed --user=test --type recipes --file ./cmd/seed/data/recipes.jsonmake lintmake test-e2eMigrations are managed with goose and live in internal/db/migrations/. They run automatically on app startup.
To add a new migration, create a file following the naming convention:
internal/db/migrations/000012_your_migration_name.sql
Migrating an existing database to goose (run once before first deploy with goose):
scp -i ~/.ssh/roasti_deploy deploy/seed_goose_versions.sql roasti@<server-ip>:/tmp/
ssh -i ~/.ssh/roasti_deploy roasti@<server-ip> "sqlite3 /var/lib/roasti/data.db < /tmp/seed_goose_versions.sql"Deployment is automated with Ansible.
Copy the inventory files and fill in your server details:
cp deploy/setup.example.ini deploy/setup.ini
cp deploy/deploy.example.ini deploy/deploy.iniFirst time setup (installs nginx, ufw, restic, creates user and directories):
ansible-playbook -i deploy/setup.ini deploy/setup.yamlAfter setup, obtain SSL certificate manually (only once):
sudo certbot certonly --nginx -d api.roasti.ruDeploy a new version:
make deployDatabase backups run automatically via systemd timer (4×/day) using restic to S3-compatible object storage.
One-time backup setup:
- Create a bucket in your object storage
- Fill in credentials:
cp deploy/backup.env.example deploy/backup.env
# set RESTIC_REPOSITORY, RESTIC_PASSWORD, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY- Run the backup playbook:
ansible-playbook -i deploy/setup.ini deploy/backup.yamlTrigger backup manually:
sudo systemctl start roasti-backup.service
sudo journalctl -u roasti-backup.service -n 50Restore:
# Copy credentials to the server if needed
scp -i ~/.ssh/roasti_deploy deploy/backup.env roasti@<server-ip>:/var/lib/roasti/backup.env
# On the server:
source /var/lib/roasti/backup.env
# List available snapshots
restic snapshots
# Restore to a temp directory
restic restore latest --target /tmp/roasti-restore/
# Replace the database (stop the service first)
sudo systemctl stop roasti
sudo cp /tmp/roasti-restore/tmp/roasti-backup-*.db /var/lib/roasti/data.db
sudo systemctl start roasti