Skip to content

Docker & Container Deployment

RetailOS primary deployment menggunakan bare metal (Go binary + systemd), tetapi Docker digunakan untuk beberapa komponen pendukung dan sebagai opsi deployment alternatif.

Uptime Kuma (Monitoring)

Uptime Kuma adalah satu-satunya komponen yang di-deploy menggunakan Docker di production:

bash
docker run -d \
  --name uptime-kuma \
  --restart=always \
  -p 3001:3001 \
  -v /opt/retailos/uptime-kuma:/app/data \
  louislam/uptime-kuma:1

Monitoring Targets

TargetURLCheck Interval
Cloud Hub Healthhttp://localhost:8090/health30s
PostgreSQLTCP port 543260s
Nginxhttp://localhost:8030s
Store Routershttp://100.x.x.x:8081/health (via Tailscale)60s
Portal Websiteshttps://ho.retailos.id120s

Docker Compose (Development/Staging)

Untuk development atau staging environment, tersedia Docker Compose setup:

yaml
# docker-compose.yml
services:
  cloud-hub:
    build:
      context: .
      dockerfile: Dockerfile.cloudhub
    ports:
      - "8090:8090"
    environment:
      - CLOUD_DB_URL=postgres://retailos:pass@db:5432/retailos
      - JWT_SECRET=dev-secret-key-minimum-32-characters
    depends_on:
      - db

  db:
    image: postgres:16-alpine
    volumes:
      - pgdata:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=retailos
      - POSTGRES_USER=retailos
      - POSTGRES_PASSWORD=pass
    ports:
      - "5432:5432"

  store-router:
    build:
      context: .
      dockerfile: Dockerfile.storerouter
    ports:
      - "8081:8081"
    environment:
      - STORE_ID=STORE-001
      - STORE_NAME=Dev Store
      - CLOUD_URL=http://cloud-hub:8090
    volumes:
      - store-data:/data

volumes:
  pgdata:
  store-data:

Dockerfiles

Tersedia tiga Dockerfile di root project:

FileTargetBase Image
Dockerfile.cloudhubCloud Hub binarygolang:1.22-alpine (build) + alpine:3.19 (runtime)
Dockerfile.storerouterStore Router binarygolang:1.22-alpine + alpine:3.19
Dockerfile.dcedgeDC Edge binarygolang:1.22-alpine + alpine:3.19

Build Pattern

Semua Dockerfile menggunakan multi-stage build:

dockerfile
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /bin/service ./cmd/cloud-hub/

# Runtime stage
FROM alpine:3.19
COPY --from=builder /bin/service /usr/local/bin/
COPY migrations/ /opt/migrations/
ENTRYPOINT ["service"]

Kapan Menggunakan Docker

SkenarioRekomendasi
Production cloud serverBare metal (Go binary + systemd)
Development lokalDocker Compose
Staging environmentDocker Compose
Store Router di tokoBare metal (systemd atau Windows service)
Monitoring (Uptime Kuma)Docker
CI/CD buildDockerfile multi-stage

RetailOS - Sistem ERP Retail Modern untuk Indonesia