Self-Hosting

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+
  • pnpm
  • A GitHub OAuth app (for authentication)

Clone and Setup

git clone https://github.com/blaze-rowland/git-env.git
cd git-env
make dev-setup

make dev-setup installs dependencies and runs database migrations.

Database Setup

Create a PostgreSQL database and run migrations:

createdb ev_production
DATABASE_URL=postgres://user:password@localhost/ev_production pnpm --filter @ev/api db:migrate

API Server

Environment Variables

Create packages/api/.env from the example:

cp packages/api/.env.example packages/api/.env

Required variables:

VariableDescription
DATABASE_URLPostgreSQL connection string
JWT_SECRETSecret for signing JWT tokens — use a long random string
GITHUB_CLIENT_IDGitHub OAuth app client ID
GITHUB_CLIENT_SECRETGitHub OAuth app client secret
GITHUB_CALLBACK_URLOAuth callback URL (e.g. https://api.example.com/auth/github/callback)
PORTPort to listen on (default: 3001)

Optional variables:

VariableDescription
AWS_ACCESS_KEY_IDAWS credentials for Secrets Manager backend
AWS_SECRET_ACCESS_KEYAWS credentials for Secrets Manager backend
AWS_REGIONDefault AWS region

Start the API Server

pnpm --filter @ev/api start

For production, use a process manager:

pnpm --filter @ev/api build
node packages/api/dist/index.js

Web Dashboard

Environment Variables

Create packages/web/.env.local from the example:

cp packages/web/.env.local.example packages/web/.env.local
VariableDescription
NEXT_PUBLIC_API_URLURL of the ev API server (e.g. https://api.example.com)
NEXTAUTH_SECRETSecret for NextAuth.js sessions
NEXTAUTH_URLPublic URL of the web dashboard (e.g. https://ev.example.com)
GITHUB_CLIENT_IDGitHub OAuth app client ID
GITHUB_CLIENT_SECRETGitHub OAuth app client secret

Start the Web Dashboard

pnpm --filter @ev/web build
pnpm --filter @ev/web start

GitHub OAuth App Setup

  1. Go to GitHub → Settings → Developer settings → OAuth Apps → New OAuth App
  2. Set Homepage URL to your web dashboard URL (e.g. https://ev.example.com)
  3. Set Authorization callback URL to https://ev.example.com/api/auth/callback/github
  4. Copy the Client ID and generate a Client Secret
  5. Set these in both packages/api/.env and packages/web/.env.local

Docker Example

A minimal Docker Compose setup for the API server:

services:
  postgres:
    image: postgres:16
    environment:
      POSTGRES_DB: ev
      POSTGRES_USER: ev
      POSTGRES_PASSWORD: changeme
    volumes:
      - pgdata:/var/lib/postgresql/data
 
  api:
    build:
      context: .
      dockerfile: packages/api/Dockerfile
    environment:
      DATABASE_URL: postgres://ev:changeme@postgres/ev
      JWT_SECRET: your-long-random-secret
      GITHUB_CLIENT_ID: your-client-id
      GITHUB_CLIENT_SECRET: your-client-secret
      GITHUB_CALLBACK_URL: https://api.example.com/auth/github/callback
      PORT: 3001
    ports:
      - "3001:3001"
    depends_on:
      - postgres
 
volumes:
  pgdata:

Client Configuration

Point the ev CLI at your self-hosted instance:

ev config set api-url https://api.example.com

Or set the environment variable:

export EV_API_URL=https://api.example.com
ev login

On this page