Deployment Guide

evergreenLast update on Jul 9, 2026
Download .md

Platform Pilihan

Project TypePlatform UtamaAlternatif
Static/AstroVercel / CloudflareGitHub Pages
Next.jsVercelNetlify
SvelteKitVercel / NetlifyCloudflare Pages
Go APIVPS + DockerFly.io, Railway
LaravelVPS + DockerLaravel Cloud
Bun/HonoVPS + DockerFly.io
NestJSVPS + DockerRailway

Environment Strategy

development → staging → production
EnvBranchPurpose
DevdevDevelopment, testing
StagingstagingPre-prod validation
ProdmainProduction, tagged release

Docker Deployment

Multi-Stage Build (Go)

FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/server

FROM gcr.io/distroless/static-debian11
WORKDIR /app
COPY --from=builder /app/server .
EXPOSE 8080
CMD ["./server"]

Bun Multi-Stage

FROM oven/bun:1 AS builder
WORKDIR /app
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile
COPY . .
RUN bun build ./src/index.ts --outdir ./out --target node

FROM oven/bun:1-slim
WORKDIR /app
COPY --from=builder /app/out .
EXPOSE 3000
CMD ["bun", "run", "index.js"]

Docker Compose (Production)

services:
  app:
    build: .
    ports:
      - "8080:8080"
    environment:
      - DATABASE_URL=${DATABASE_URL}
      - REDIS_URL=${REDIS_URL}
    depends_on:
      - db
      - redis

  db:
    image: postgres:16-alpine
    volumes:
      - pgdata:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine

volumes:
  pgdata:

Environment Variables

  1. Never commit .env files.
  2. Gunakan .env.example dengan dummy values.
  3. Production secrets: gunakan Docker secrets, cloud provider secret manager, atau env injection.
# .env.example
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
REDIS_URL=redis://localhost:6379
JWT_SECRET=change-me-in-production
PORT=8080

Checklist Pre-Deploy

  • Semua test passing
  • Lint & type check bersih
  • Migration dijalankan (jika ada DB change)
  • Environment variables sudah di-set
  • Health check endpoint tersedia
  • Logging sudah configured
  • Rollback plan siap

Health Check

Setiap service WAJIB punya health check endpoint:

// Go
app.Get("/health", func(c *fiber.Ctx) error {
    return c.JSON(fiber.Map{"status": "ok"})
})
// Hono
app.get("/health", (c) => c.json({ status: "ok", uptime: process.uptime() }));

Rollback

Gunakan Docker image tags untuk rollback cepat:

# Deploy specific version
docker pull registry/app:v1.2.3
docker-compose up -d

# Rollback
docker pull registry/app:v1.2.2
docker-compose up -d