Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Deploying Go Services to Do | Go Programming Bootcamp lesson | BraveProgrammer
  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 47 of 60

·Go

Deploying 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: 
 

   

   
  
    
       
  
    
      
         
    
      
        
         
        
          
apps/v1
kind:
Deployment
metadata:
name:
go-app
spec:
replicas:
3
selector:
matchLabels:
app:
go-app
template:
metadata:
labels:
app:
go-app
spec:
containers:
-
name:
go-app
image:
ghcr.io/yourname/go-app:latest
ports:
-
containerPort:
8080

Create a Service (NodePort or LoadBalancer) to expose the app.

Info

Set GOMAXPROCS to the number of CPU cores inside the container for optimal concurrency.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from Go Programming BootcampBrowse activities
Previous lessonBuilding a HTTP/2 Server with TLSContinue to lesson 48Versioning & Release Management (Semantic Import Versioning)Back to Go Programming Bootcamp curriculum