henriqueatila/golang-gin-best-practices / skills/golang-gin-deploy
golang-gin-deploy
VerifiedDeploy Go Gin APIs with Docker, docker-compose, Kubernetes. Use when Dockerizing a Go app, setting up docker-compose, deploying to K8s, or configuring CI/CD and health probes.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.4 KB |
| metadata.json | config | 481 B |
| references/configuration-docker-quickref.md | markdown | 2.9 KB |
| references/configuration-health-and-config-loader.md | markdown | 3.1 KB |
| references/docker-compose-dev-setup.md | markdown | 3.4 KB |
| references/docker-compose-test-and-prod.md | markdown | 5.0 KB |
| references/dockerfile-build-args-security-and-healthcheck.md | markdown | 3.2 KB |
| references/dockerfile-multistage-and-base-images.md | markdown | 3.1 KB |
| references/dockerfile-size-optimization-and-complete-example.md | markdown | 3.1 KB |
| references/kubernetes-complete-helm-cicd.md | markdown | 3.5 KB |
| references/kubernetes-deployment-service-config.md | markdown | 3.5 KB |
| references/kubernetes-probes-hpa-ingress-pvc.md | markdown | 3.8 KB |
| references/observability-docker-stack-and-shutdown.md | markdown | 4.0 KB |
| references/observability-metrics-logs-sampling.md | markdown | 4.4 KB |
| references/observability-otel-sdk-and-middleware.md | markdown | 4.2 KB |
references/configuration-docker-quickref.md
View on GitHub# Configuration — .dockerignore, Dockerfile, and docker-compose Quick Reference
> These are condensed quick-reference snippets. For full patterns see the dedicated dockerfile-* and docker-compose-* reference files.
## .dockerignore
```dockerignore
.git; .gitignore
*.test; *.out; coverage.html
.env; .env.*
docker-compose*.yml; air.toml
*.md; docs/; plans/
.github/
```
**Why:** Excluding `.git` and `*.md` keeps the build context small. Excluding `.env` prevents secrets from leaking into the image. See [dockerfile-size-optimization-and-complete-example.md](dockerfile-size-optimization-and-complete-example.md) for full `.dockerignore`.
---
## Multi-Stage Dockerfile (Quick Reference)
```dockerfile
# syntax=docker/dockerfile:1
# Stage 1: Builder
FROM golang:1.24-bookworm AS builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build \
-ldflags="-s -w" -trimpath -o /app/server ./cmd/api
# Stage 2: Runtime
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=builder /app/server /server
EXPOSE 8080
ENTRYPOINT ["/server"]
```
`CGO_ENABLED=0` is mandatory for distroless — produces a statically linked binary. Final image ~10 MB vs ~800 MB with the golang base. See [dockerfile-multistage-and-base-images.md](dockerfile-multistage-and-base-images.md) for full explanation with BuildKit cache mounts, build args, and base image comparison.
---
## docker-compose for Local Development (Quick Reference)
```yaml
# docker-compose.yml
services:
app:
build: .
ports: ["8080:8080"]
environment:
PORT: "8080"; DATABASE_URL: "postgres://myapp:myapp@postgres:5432/myapp?sslmode=disable"
REDIS_URL: "redis://redis:6379"; JWT_SECRET: "dev-secret"; GIN_MODE: "debug"
depends_on:
postgres: { condition: service_healthy }
redis: { condition: service_healthy }
volumes: [.:/app] # for Air hot reload — remove in production
postgres:
image: postgres:17-alpine
environment: { POSTGRES_DB: myapp, POSTGRES_USER: myapp, POSTGRES_PASSWORD: myapp }
ports: ["5432:5432"]
volumes: [postgres_data:/var/lib/postgresql/data]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U myapp -d myapp"]
interval: 5s; timeout: 5s; retries: 5
redis:
image: redis:7-alpine; ports: ["6379:6379"]
healthcheck:
test: ["CMD", "redis-cli", "ping"]; interval: 5s; timeout: 3s; retries: 5
volumes:
postgres_data:
```
For Air hot reload dev image, integration test compose, production-like compose, and full example: see [docker-compose-dev-setup.md](docker-compose-dev-setup.md) and [docker-compose-test-and-prod.md](docker-compose-test-and-prod.md).
For migration running in Docker: see the **golang-gin-database** skill (`references/migrations.md`).
> For health check handler and config loader: see [configuration-health-and-config-loader.md](configuration-health-and-config-loader.md).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |