Skip to content

Local Development — Cloud Backend

  • Go 1.26+
  • SQL Server running locally (Docker recommended) or Azure SQL access
  • Flyway CLI (for migrations)
Terminal window
cd Backend
cp .env.example .env
# Edit .env with your values
go mod download

All variables are documented in Backend/.env.example. Key ones for local development:

VariableExample valueNotes
DATABASE_URLsqlserver://sa:Pass@localhost:1433?database=monozu&encrypt=disableLocal SQL Server
SECRET_KEYchange-me-to-a-long-random-stringMust be ≥32 chars in prod
APP_ENVdevelopmentEnables ANSI log colors
IS_DEVtrueForces SQL auth over Managed Identity
PORT8000API listen port
APP_BASE_URLhttp://localhost:3000Frontend SPA URL (for OAuth redirects)
ALLOW_ORIGINShttp://localhost:3000,http://127.0.0.1:3000CORS allowed origins

If testing the Management ↔ Cloud integration locally, also set:

VariableValue
CLOUD_INTERNAL_API_TOKENAny string — must match Management’s value
CLOUD_WEBHOOK_HMAC_SECRETAny 32+ char string — must match Management’s value
MANAGEMENT_API_URLhttp://localhost:8080

Only needed if testing SSO locally:

VariableValue
MS_CLIENT_IDApp registration client ID
MS_CLIENT_SECRETClient secret
API_PUBLIC_URLhttp://localhost:8000 (must match Entra redirect URI)
Terminal window
docker run --name monozu-sql \
-e ACCEPT_EULA=Y \
-e SA_PASSWORD=YourStr0ngP@ss \
-p 1433:1433 \
-d mcr.microsoft.com/mssql/server:2022-latest
Terminal window
flyway \
-url="jdbc:sqlserver://localhost:1433;databaseName=monozu;encrypt=false" \
-user=sa \
-password=YourStr0ngP@ss \
-locations=filesystem:db/migration \
migrate
Terminal window
go run ./cmd/server
# API available at http://localhost:8000

Or build and run:

Terminal window
go build -o ./bin/server ./cmd/server
./bin/server
Terminal window
go test ./...

The Dockerfile is a multi-stage build (Go builder → Alpine runtime):

Terminal window
docker build -t monozu-backend .
docker run -p 8000:8000 --env-file .env monozu-backend
ProblemFix
HTTP 431 on Entra ID redirectIncrease HTTP_READ_BUFFER_BYTES=65536
Refresh cookie not sentCheck REFRESH_COOKIE_SAMESITE — use lax or none for cross-origin, strict for same-origin
tenant pending on loginActivate the tenant via Management service first
SQL auth failsEnsure IS_DEV=true is set when using DATABASE_URL