In this video, we are going to be taking a look at how we can evolve our single stage dockerfile into a multistage dockerfile.
Finished Dockerfile:
FROM golang:latest AS builder
WORKDIR /app
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o main main.go
# Second stage of our application
FROM alpine:latest AS production
COPY --from=builder /app .
CMD ["./main"]
Commands in Video:
$ docker build -t multistage-go-app .
$ docker run -it -p 3000:3000 multistage-go-app
$ docker run -d 3000:3000 multistage-go-app
$ docker images | grep my-go-app
$ docker images | grep multistage-go-app