(01)Build and start
Linux
1docker compose up -d --build2docker compose ps3curl http://localhost:8080/healthGo API with MongoDB — DevOps-Pipeline-Go Minikube/docker-compose pattern
docker-compose.yml
1version: "3"2 3services:4 app:5 build: .6 ports:7 - "8080:8080"8 depends_on:9 - db10 environment:11 SERVER_PORT: 808012 MONGO_URI: mongodb://db:2701713 security_opt:14 - no-new-privileges:true15 16 db:17 image: mongo:latest18 restart: always19 ports:20 - "27017:27017"21 security_opt:22 - no-new-privileges:trueDockerfile
1FROM golang:1.22-alpine AS builder2WORKDIR /app3COPY go.mod go.sum ./4RUN go mod download5COPY . .6RUN CGO_ENABLED=0 go build -o server .7 8FROM alpine:3.199WORKDIR /app10COPY --from=builder /app/server .11EXPOSE 808012CMD ["./server"]Step 01
1docker compose up -d --build2docker compose ps3curl http://localhost:8080/health