docker image build --target
Uso Básico
# Estágio de build
FROM golang:1.18.1 AS build
WORKDIR /build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# Estágio final
FROM alpine:3.20.2 AS app
WORKDIR /app
COPY --from=build /build/main .
CMD ["./main"]docker build --target build -t myapp:build .docker build --target app -t myapp:latest .
Vantagens
Comando Completo
Referências
Last updated