Documentation

Settings

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

  1. Install Fly CLI:

  2. Authentication:

    fly auth signup

    Verify correct account:

    fly auth whoami

Initial Setup

  1. 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.

  2. Git Repository Setup:

    git init
    git remote add origin <ORIGIN_URL>

Security Configuration

  1. GitHub Configuration:

    • Generate Fly API token at Fly.io tokens page
    • Add token to GitHub repository secrets as FLY_API_TOKEN
  2. 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

  1. 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

  2. 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 environment
  • dev branch → Staging environment

Optional Configurations

  1. Email Service

  2. Error Monitoring

  3. Database Management

Local Deployment

Using Fly

Simple deployment using Fly CLI:

fly deploy

Using Docker

  1. Modify Dockerfile:
# prepare for litefs
VOLUME /litefs
ADD . .

EXPOSE ${PORT}
ENTRYPOINT ["/myapp/other/docker-entry-point.sh"]

  1. 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

  1. 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

  1. Environment Management

    • Keep production and staging environments separate
    • Use appropriate secrets for each environment
    • Test deployments in staging first
  2. Database Considerations

    • Always backup before major changes
    • Use proper migration strategies
    • Monitor database performance
  3. Security Measures

    • Rotate secrets regularly
    • Use appropriate access controls
    • Monitor deployment logs
  4. 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.