2 likes
·
117 reads
5 comments
Where we drop the go compiler in the second example? Can you describe this?
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.
But it is already install in the first stage, so it takes storage as well, I did not understand why big thing is not big
Previous stages are ephemeral, they are just there to help us achieve final stage.
Final stage can import (copy) things (e.g. our built binary) from previous stages, and then, previous stages with all their contents will be gone. (actually they are also cached for next builds, but it will not be a part of final stage)
Arsham Arya aha I catch you now. It is very interesting to learn