golang-gin-deploy

Containerize and deploy Go Gin APIs with multi-stage Docker builds and docker-compose.

1|Updated Jul 4, 2026
One-click install
npx skills add https://github.com/trungenglish/SHOPWISE --skill golang-gin-deploy-trungenglish
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-gin-deploy
Source: https://github.com/trungenglish/SHOPWISE/tree/main/.agents/skills/golang-gin-deploy
Command: npx skills add https://github.com/trungenglish/SHOPWISE --skill golang-gin-deploy-trungenglish

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Deploying a Go Gin API to production involves many error-prone decisions: choosing base images, writing multi-stage Dockerfiles, wiring docker-compose services with health checks, and adding observability. This Skill provides production-tested patterns for each step so you avoid common pitfalls like bloated images, leaked secrets, and hanging health probes. ## Core Features & Use Cases - Multi-Stage Docker Builds: Build ~10 MB distroless images with CGO_ENABLED=0, ldflags stripping, BuildKit cache mounts, and non-root execution. - Docker Compose Environments: Set up development stacks with Air hot reload, integration test compose files, and production-like compose with resource limits and health checks. - Health Checks & 12-Factor Config: Implement /health endpoints with DB ping timeouts, readiness vs liveness probes, and environment-variable-based configuration with fail-fast validation. - OpenTelemetry Observability: Add tracing, RED metrics, log-trace correlation, and Jaeger/Prometheus/Grafana compose stacks with graceful shutdown. - Use Case: You have a Gin API running locally and need to ship it. Use this Skill to generate a hardened production Dockerfile, a docker-compose stack with Postgres and Redis health checks, and OTel instrumentation before your first deploy. ## Quick Start Dockerize my Go Gin API with a multi-stage Dockerfile and a docker-compose setup including Postgres, Redis, and health checks.

Frequently Asked Questions about golang-gin-deploy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I Dockerize a Go Gin API for production?▼

Use a multi-stage Dockerfile: build with golang:1.24-bookworm using CGO_ENABLED=0 and -ldflags="-s -w" -trimpath, then copy the binary into gcr.io/distroless/static-debian12:nonroot. This produces a statically linked ~10 MB image running as a non-root user.

What base image should I use for a Go Docker container?▼

Distroless static-debian12 (~2 MB) is recommended for production since it has no shell, reducing attack surface. Use Alpine when you need shell access or apk packages, and scratch only for absolute minimum size when you can copy TLS certificates manually.

How do I set up docker-compose health checks for Postgres and Redis?▼

Add healthcheck blocks using pg_isready for Postgres and redis-cli ping for Redis, then reference them with depends_on and condition: service_healthy. This ensures the app container starts only after the database is actually ready to accept connections.

Why does my Docker HEALTHCHECK fail with distroless images?▼

Distroless images have no shell, curl, or wget, so shell-based health checks cannot run. Embed the check in your Go binary with a -health-check flag that performs an HTTP GET against /health and exits non-zero on failure.

Can I pass secrets as Docker build arguments?▼

No, ARG values are visible in docker history and image metadata. Use BuildKit secret mounts with --mount=type=secret instead, which keeps sensitive values like tokens out of image layers.

What is the difference between liveness and readiness probes?▼

Liveness checks whether the process is alive and triggers a container restart on failure. Readiness checks whether the app can serve traffic, such as database reachability, and removes it from the load balancer without restarting.