Thanks for your attention.
When we write this line:
FROM golang:1.18-alpine3.15 AS builder
We are actually using an alpine image with go compiler version 1.18 pre-installed. (as our builder stage)
At the lines:
FROM alpine:3.15 AS production
COPY --from=builder /app/main .
We are importing the compiled (binary) of our app from the builder stage (previous stage) into a new alpine image that doesn't have the golang compiler preinstalled.
So we didn't directly drop it, we just don't import or install it in next stages because we don't need it anymore.