Lesson 47 of 60
GoDeploying Go Services to Docker & Kubernetes
25 minutes
Course progress78%
Dockerfile (multi‑stage)
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /src
COPY . .
RUN CGO_ENABLED=0 go build -o /app ./cmd/app
# Runtime stage
FROM alpine:latest
RUN addgroup -S app && adduser -S -G app app
USER app
COPY --from=builder /app /app
ENTRYPOINT ["/app"]
Kubernetes Deployment
apiVersion: