We will use Docker build kit since it’s a new fancy way of building docker images. Dockerfile 1 2 3 4 5 6 7 8 9 10 11 # Pull the image and call it base FROM golang:1.13.7-alpine3.11 # Copy the code COPY src /codebase/src RUN ls /codebase/src/main.go # Build the binary RUN cd /codebase && go build -v -o /codebase/bin/server ./src/main.go # Set the env which will be available at runtime ENV PORT = 8080 # Specify the run command for the binary CMD [ "sh" , "-c" , "/codebase/bin/server" ] Dockerfile 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # Pull the image and call it base FROM golang:1.13.7-alpine3.11 as stage1 # Copy the code COPY src /codebase/src RUN ls /codebase/src/main.go # Build the binary RUN cd /codebase && go build -v -o /codebase/bin/server ./src/main.go FROM alpine:3.11 as stage2 # We…