Local Setup
This guide walks you through setting up a complete development environment for Rack Gateway.
Prerequisites
Section titled “Prerequisites”Before starting, ensure you have these tools installed:
| Tool | Version | Purpose |
|---|---|---|
| Go | 1.22+ | Backend development |
| Docker | Latest | Container runtime |
| Node.js | 20+ | Web frontend tooling |
| Bun | 1.3+ | Package manager and runtime |
| Task | 3.0+ | Task runner |
| mise | Latest | Environment variable management |
Installing Prerequisites
Section titled “Installing Prerequisites”# Install Homebrew if not already installed/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Gobrew install go
# Install Docker Desktopbrew install --cask docker
# Install Node.jsbrew install node
# Install Buncurl -fsSL https://bun.sh/install | bash
# Install Taskbrew install go-task
# Install misebrew install mise# Install Go (Ubuntu/Debian)sudo add-apt-repository ppa:longsleep/golang-backportssudo apt updatesudo apt install golang-go
# Install Dockercurl -fsSL https://get.docker.com | shsudo usermod -aG docker $USER
# Install Node.js via nvmcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bashnvm install 20
# Install Buncurl -fsSL https://bun.sh/install | bash
# Install Tasksh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
# Install misecurl https://mise.run | shQuick Start
Section titled “Quick Start”-
Clone the repository
Terminal window git clone https://github.com/docspring/rack-gateway.gitcd rack-gateway -
Install dependencies
Terminal window # Install tooling and dependenciestask dev-setuptask go:depstask web:depstask mock-oauth:deps -
Configure environment
Terminal window # Create local configurationcp mise.local.toml.example mise.local.toml# Edit with your Google OAuth credentials (optional for mock mode)# See "Google OAuth Setup" section below -
Start development environment
Terminal window task dev -
Verify services are running
Terminal window # Gateway healthcurl http://localhost:8447/api/v1/health# Expected: {"status":"ok"}# Open Web UIopen http://localhost:5223
Configuration
Section titled “Configuration”Environment Variables
Section titled “Environment Variables”Rack Gateway uses mise for environment variable management. Configuration is layered:
| File | Purpose | Git Status |
|---|---|---|
mise.toml | Default configuration | Checked in |
mise.local.toml | Local overrides | Gitignored |
Create your local configuration:
cp mise.local.toml.example mise.local.tomlKey Configuration Options
Section titled “Key Configuration Options”[env]# Google OAuth (optional - mock OAuth works by default)GOOGLE_CLIENT_ID = "your-client-id.apps.googleusercontent.com"GOOGLE_CLIENT_SECRET = "your-client-secret"GOOGLE_ALLOWED_DOMAIN = "yourdomain.com"
# Debug loggingLOG_LEVEL = "debug"
# Custom session secret (optional)APP_SECRET_KEY = "your-local-session-secret"Database Configuration
Section titled “Database Configuration”The development environment uses PostgreSQL in Docker. Connection details:
| Setting | Value |
|---|---|
| Host | localhost |
| Port | 55432 |
| Database | gateway_dev |
| User | postgres |
| Password | postgres |
# Connect to development databasedocker exec -it rack-gateway-postgres-1 psql -U postgres -d gateway_dev
# Run migrations manuallytask db:migrateGoogle OAuth Setup (Optional)
Section titled “Google OAuth Setup (Optional)”For testing with real Google OAuth (instead of mock):
-
Create Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select existing
-
Enable Google+ API
- Navigate to “APIs & Services” → “Library”
- Search for “Google+ API”
- Click “Enable”
-
Configure OAuth Consent Screen
- Go to “APIs & Services” → “OAuth consent screen”
- Choose “Internal” for Google Workspace users
- Fill required fields:
- App name: “Rack Gateway (Dev)”
- Support email: your email
- Add scopes:
openid,email,profile
-
Create OAuth Credentials
- Go to “APIs & Services” → “Credentials”
- Click ”+ CREATE CREDENTIALS” → “OAuth client ID”
- Choose “Web application”
- Add redirect URI:
http://localhost:8447/api/v1/auth/cli/callback - Save credentials
-
Update Configuration
mise.local.toml [env]GOOGLE_CLIENT_ID = "your-client-id.apps.googleusercontent.com"GOOGLE_CLIENT_SECRET = "your-client-secret"GOOGLE_ALLOWED_DOMAIN = "yourdomain.com"# Disable mock OAuthMOCK_OAUTH_ENABLED = "false"
Development Workflows
Section titled “Development Workflows”Starting the Full Stack
Section titled “Starting the Full Stack”# Start all services (Gateway, Web UI, Mock OAuth, Mock Convox)task dev
# View logstask dev:logs
# Stop all servicestask dev:downRunning Components Individually
Section titled “Running Components Individually”For debugging specific components:
# Build all binariestask build
# Run gateway server directly./bin/rack-gateway-api
# Run CLI commands./bin/rack-gateway login local http://localhost:8447./bin/rack-gateway convox appsTesting the Authentication Flow
Section titled “Testing the Authentication Flow”-
Start development environment
Terminal window task dev -
Login via Web UI
- Open
http://localhost:5223 - Click “Login with Google”
- Complete OAuth flow (mock OAuth auto-approves)
- Open
-
Login via CLI
Terminal window # Build CLItask go:build:cli# Login to local gateway./bin/rack-gateway login local http://localhost:8447# Browser opens for OAuth, then CLI stores token -
Test proxied commands
Terminal window ./bin/rack-gateway convox rack./bin/rack-gateway convox apps./bin/rack-gateway convox ps -a myapp
Working with the Web UI
Section titled “Working with the Web UI”# Start just the web dev server (assumes gateway is running)cd web && bun run dev
# Run web teststask web:test
# Run E2E teststask web:e2eDatabase Operations
Section titled “Database Operations”# Run migrationstask db:migrate
# Reset database (deletes all data)task db:reset
# Access psqldocker exec -it rack-gateway-postgres-1 psql -U postgres -d gateway_devTroubleshooting
Section titled “Troubleshooting”Port Conflicts
Section titled “Port Conflicts”If ports are already in use:
# Find process using a portlsof -i :8447
# Kill processkill -9 <PID>
# Or change ports in mise.local.tomlDocker Issues
Section titled “Docker Issues”# Restart Docker containerstask docker:downtask docker:up
# Rebuild imagestask docker:reset
# Check container logsdocker logs rack-gateway-postgres-1OAuth Errors
Section titled “OAuth Errors”- “redirect_uri mismatch”: Ensure the redirect URI in Google Cloud Console exactly matches
http://localhost:8447/api/v1/auth/cli/callback - “Invalid client”: Verify
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETinmise.local.toml
CLI Configuration Issues
Section titled “CLI Configuration Issues”The CLI stores configuration in different locations:
| Environment | Location |
|---|---|
| Development | ./config/cli/ |
| Production | ~/.config/rack-gateway/ |
In development, set:
export GATEWAY_CLI_CONFIG_DIR=./config/cliDatabase Connection Issues
Section titled “Database Connection Issues”# Verify PostgreSQL is runningdocker ps | grep postgres
# Test connectiondocker exec -it rack-gateway-postgres-1 psql -U postgres -c "SELECT 1"
# Check database existsdocker exec -it rack-gateway-postgres-1 psql -U postgres -c "\l"IDE Setup
Section titled “IDE Setup”VS Code
Section titled “VS Code”Recommended extensions:
- Go - Go language support
- ESLint - JavaScript/TypeScript linting
- Prettier - Code formatting
- Docker - Docker support
Settings (.vscode/settings.json):
{ "go.lintTool": "golangci-lint", "go.lintFlags": ["--fast"], "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "[go]": { "editor.defaultFormatter": "golang.go" }}GoLand / IntelliJ
Section titled “GoLand / IntelliJ”- Enable “Go Modules” integration
- Configure golangci-lint as external tool
- Set up Biome for TypeScript