Deployment
The Ellemment Stack supports deployment through Fly.io and Docker, providing flexibility and scalability for your application. This guide walks you through the deployment process step by step.
Fly.io Deployment
Prerequisites
-
Install Fly CLI:
- Visit Fly.io's installation guide
- Note: Use
flyctl
iffly
commands don't work
-
Authentication:
fly auth signup
Verify correct account:
fly auth whoami
Initial Setup
-
Create Applications:
# Production app fly apps create [YOUR_APP_NAME] ,[object Object],
fly apps create [YOUR_APP_NAME]-staging
Ensure app names match your
fly.toml
configuration. -
Git Repository Setup:
git init git remote add origin <ORIGIN_URL>
Security Configuration
-
GitHub Configuration:
- Generate Fly API token at Fly.io tokens page
- Add token to GitHub repository secrets as
FLY_API_TOKEN
-
Application Secrets:
# Production secrets fly secrets set \ SESSION_SECRET=$(openssl rand -hex 32) \ HONEYPOT_SECRET=$(openssl rand -hex 32) \ --app [YOUR_APP_NAME] ,[object Object],
fly secrets set ,[object Object], SESSION_SECRET=$(openssl rand -hex 32) ,[object Object], HONEYPOT_SECRET=$(openssl rand -hex 32) ,[object Object], ALLOW_INDEXING=false ,[object Object], --app [YOUR_APP_NAME]-staging
Database Setup
-
Create Persistent Volumes:
# Production volume fly volumes create data \ --region sjc \ --size 1 \ --app [YOUR_APP_NAME] ,[object Object],
fly volumes create data ,[object Object], --region sjc ,[object Object], --size 1 ,[object Object], --app [YOUR_APP_NAME]-staging
-
Configure Consul:
# Production Consul fly consul attach --app [YOUR_APP_NAME] ,[object Object],
fly consul attach --app [YOUR_APP_NAME]-staging
Continuous Deployment
The stack includes GitHub Actions for automated deployments:
main
branch → Production environmentdev
branch → Staging environment
Optional Configurations
-
Email Service
- Configure email provider
- See email documentation for setup
-
Error Monitoring
- Set up error tracking
- Reference monitoring documentation
-
Database Management
- Connect to production database
- Database seeding instructions
- See database documentation
Local Deployment
Using Fly
Simple deployment using Fly CLI:
fly deploy
Using Docker
- Modify Dockerfile:
# prepare for litefs VOLUME /litefs ADD . .
EXPOSE ${PORT} ENTRYPOINT ["/myapp/other/docker-entry-point.sh"]
- Create Entry Point Script:
#!/bin/sh -ex
npx prisma migrate deploy sqlite3 /litefs/data/sqlite.db "PRAGMA journal_mode = WAL;" sqlite3 /litefs/data/cache.db "PRAGMA journal_mode = WAL;" npm run start
- Build and Run:
# Build container docker build -t ellemment-stack . \ -f other/Dockerfile \ --build-arg COMMIT_SHA=$(git rev-parse --short HEAD) ,[object Object], ,[object Object], ,[object Object],
docker run -d ,[object Object], -p 8081:8081 ,[object Object], -e SESSION_SECRET='somesecret' ,[object Object], -e HONEYPOT_SECRET='somesecret' ,[object Object], -e FLY='false' ,[object Object], -v ~/litefs:/litefs ,[object Object], ellemment-stack
Access your application at http://localhost:8081
Deployment Best Practices
-
Environment Management
- Keep production and staging environments separate
- Use appropriate secrets for each environment
- Test deployments in staging first
-
Database Considerations
- Always backup before major changes
- Use proper migration strategies
- Monitor database performance
-
Security Measures
- Rotate secrets regularly
- Use appropriate access controls
- Monitor deployment logs
-
Performance Optimization
- Configure appropriate instance sizes
- Monitor resource usage
- Set up proper scaling rules
For more details about database configuration, see the database documentation. For monitoring setup, check the monitoring documentation.