Platform Pilihan
| Project Type | Platform Utama | Alternatif |
|---|---|---|
| Static/Astro | Vercel / Cloudflare | GitHub Pages |
| Next.js | Vercel | Netlify |
| SvelteKit | Vercel / Netlify | Cloudflare Pages |
| Go API | VPS + Docker | Fly.io, Railway |
| Laravel | VPS + Docker | Laravel Cloud |
| Bun/Hono | VPS + Docker | Fly.io |
| NestJS | VPS + Docker | Railway |
Environment Strategy
development → staging → production
| Env | Branch | Purpose |
|---|---|---|
| Dev | dev | Development, testing |
| Staging | staging | Pre-prod validation |
| Prod | main | Production, 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
- Never commit
.envfiles. - Gunakan
.env.exampledengan dummy values. - 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