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:1Monitoring Targets
| Target | URL | Check Interval |
|---|---|---|
| Cloud Hub Health | http://localhost:8090/health | 30s |
| PostgreSQL | TCP port 5432 | 60s |
| Nginx | http://localhost:80 | 30s |
| Store Routers | http://100.x.x.x:8081/health (via Tailscale) | 60s |
| Portal Websites | https://ho.retailos.id | 120s |
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:
| File | Target | Base Image |
|---|---|---|
Dockerfile.cloudhub | Cloud Hub binary | golang:1.22-alpine (build) + alpine:3.19 (runtime) |
Dockerfile.storerouter | Store Router binary | golang:1.22-alpine + alpine:3.19 |
Dockerfile.dcedge | DC Edge binary | golang: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
| Skenario | Rekomendasi |
|---|---|
| Production cloud server | Bare metal (Go binary + systemd) |
| Development lokal | Docker Compose |
| Staging environment | Docker Compose |
| Store Router di toko | Bare metal (systemd atau Windows service) |
| Monitoring (Uptime Kuma) | Docker |
| CI/CD build | Dockerfile multi-stage |