🚀 Get 25% off access to all my premium courses - use discount code FUNCMAIN at checkout - view the pricing page now!

Video:

Multistage Dockerfiles For Your Go Apps!

March 12, 2023

Course Instructor: Elliot Forbes

Hey Gophers! My name is Elliot and I'm the creator of TutorialEdge and I've been working with Go systems for roughly 5 years now.

Twitter: @Elliot_f

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