Blog của Sang

Docker Multi-Stage Build cho Image Nhỏ

Tại sao?

Image nhỏ = deploy nhanh hơn, ít vulnerability hơn.

Ví dụ Go

FROM golang:1.22 AS builder
COPY . .
RUN CGO_ENABLED=0 go build -o app .

FROM scratch
COPY --from=builder /app /app
CMD ["/app"]

Image chỉ ~10MB thay vì 800MB+.


← Back to all posts