Developer Documentation & Multi-Git Architecture
StageDock automates the lifecycle of ephemeral pull request environments, static AST quality gates, and database seed fixtures across GitHub, GitLab, Bitbucket, and self-hosted Git repositories.
1. CLI Quickstart & Diagnostic Check
Set up StageDock locally or inside your CI/CD runner using the official Node CLI.
The StageDock CLI inspects your local environment for Docker Engine (v24+), PostgreSQL (v16), Redis, and network bridge health. Run the command below in your project root:
1# Initialize StageDock in your project repository2pnpm dlx stagedock@latest init34# Run infrastructure pre-flight diagnostics5pnpm dlx stagedock@latest doctor67# Optional: Link to an existing remote workspace8stagedock link --workspace main-workspace2. Universal Git Webhook Integration
Connect GitHub, GitLab Cloud/Omnibus, Bitbucket, or self-hosted Git repositories to trigger automated previews.
In GitHub: Go to Repository Settings ➔ Webhooks ➔ Add webhook. Configure with:
- Payload URL: https://api.stagedock.dev/api/webhooks/git (or /api/webhooks/github)
- Content type: application/json
- Secret: Your generated HMAC Secret
- Security Verification: Validated via
X-Hub-Signature-256 - Events: Pull requests (opened, synchronize, closed, reopened)
1Payload URL: https://api.stagedock.dev/api/webhooks/git2Content type: application/json3Secret: [Your Webhook Secret from Project Settings]4SSL verification: Enable SSL verification56Header Sent: X-Hub-Signature-256: sha256=<hmac_hash>7Events to trigger:8[X] Let me select individual events9 [X] Pull requests (opened, synchronize, closed, reopened)10 [X] Pushes (optional for trunk validation)3. Multi-Stage Dockerfile Format
Deterministic image builds, layer caching, and unprivileged user security.
StageDock compiles an isolated container for each pull request. Ensure your project provides a standard multi-stage Dockerfile in the repository root. Containers must listen on port 3000 and run under an unprivileged user (USER node):
1# Multi-stage corporate Node.js Dockerfile for StageDock2FROM node:20-alpine AS base3WORKDIR /app4RUN apk add --no-cache libc6-compat5ENV NODE_ENV=production67# Install dependencies8FROM base AS deps9COPY package.json pnpm-lock.yaml* package-lock.json* ./10RUN npm ci --omit=dev1112# Builder stage13FROM base AS builder14COPY --from=deps /app/node_modules ./node_modules15COPY . .16RUN npm run build1718# Runner stage (unprivileged non-root user)19FROM base AS runner20USER node21COPY --from=builder /app ./22EXPOSE 300023ENV PORT=300024CMD ["npm", "start"]4. Project .env Secret Vault
Encrypted environment configuration injected directly into ephemeral containers.
Store your API tokens, payment credentials, and microservice hosts inside the Project Vault in the Client Portal. StageDock injects these variables during container creation, replacing database connection strings with the dynamically provisioned ephemeral PostgreSQL instance:
1# Runtime Vault Variables (Injected automatically per PR container)2DATABASE_URL=postgresql://sandbox_user:secret@postgres-sandbox:5432/pr_42_db3NEXT_PUBLIC_API_URL=https://api.stagedock.dev4REDIS_URL=redis://redis:6379/15JWT_SECRET=stagedock_ephemeral_runtime_token_key5. Traefik Wildcard Routing & SSL Ingress
Automatic subdomain assignment and zero-downtime routing table registration.
Every preview environment is assigned a scoped wildcard domain, such as pr-42.stagedock.localhost (locally) or pr-42-orders.stagedock.dev (production). Traefik dynamically binds incoming requests to the target container:
1# Traefik Ingress Dynamic Routing Rule2# Automatically generated for each PR sandbox container34http:5 routers:6 pr-42-router:7 rule: "Host(`pr-42.stagedock.localhost`) || Host(`pr-42.stagedock.dev`)"8 service: pr-42-service9 entryPoints:10 - web11 - websecure12 tls:13 certResolver: letsencrypt14 services:15 pr-42-service:16 loadBalancer:17 servers:18 - url: "http://sandbox-container-42:3000"