Appearance
Docker Build & Deployment
Building Images
Backend (Go multi-stage build)
bash
# Using Dockerfile.backend (context: ./backend)
docker compose build backend
# Or manually:
docker build -t anjungan-backend -f Dockerfile.backend ./backendThe backend Dockerfile:
- Build stage —
golang:1.25-alpinecompiles with-ldflags="-s -w"for a smaller binary - Runtime stage —
alpine:3.20includesca-certificates,openssh-client,docker-cli,curl - Runs as non-root user
anjungan(UID 1000)
Frontend (npm build + nginx)
bash
# Using Dockerfile.frontend (context: project root)
docker compose build frontend
# Or manually:
docker build -t anjungan-frontend -f Dockerfile.frontend .The frontend Dockerfile:
- Build stage —
node:22-alpinerunsnpm installthennpm run build - Runtime stage —
nginx:1.27-alpineserves the static build output - Nginx config: SPA fallback, immutable cache for
/_app/, proxy/api/*to backend
Tagging Convention
Images are tagged for the private Zot registry at registry.edsuwarna.xyz:
| Tag Pattern | When | Example |
|---|---|---|
main-latest | Push to main | registry.edsuwarna.xyz/anjungan-backend:main-latest |
main-{sha} | Push to main | registry.edsuwarna.xyz/anjungan-backend:main-a1b2c3d |
release-latest | Tag push v* | registry.edsuwarna.xyz/anjungan-backend:release-latest |
v0.3.0 | Tag push v* | registry.edsuwarna.xyz/anjungan-backend:v0.3.0 |
CI/CD Pipeline (GitHub Actions)
The workflow .github/workflows/docker-build-push.yml:
- On push to
main— builds both images, pushes withmain-latest+main-{sha}tags - On tag push
v*— builds both images, pushes withrelease-latest+ version tags
Prerequisites
Set these GitHub Actions secrets:
| Secret | Description |
|---|---|
REGISTRY_URL | Zot registry URL (e.g. registry.edsuwarna.xyz) |
REGISTRY_USER | Registry deploy user |
REGISTRY_PASSWORD | Registry deploy password |
Rebuild & Deploy on Server
bash
# Pull latest code
git pull origin main
# Rebuild and restart
docker compose build
docker compose up -d --force-recreate
# Verify
docker compose ps
docker compose logs --tail=20 backend