Sign in
Log inSign up
Arsham Arya

2 likes

·

117 reads

5 comments

Akbarshoh Ismoilov
Akbarshoh Ismoilov
Mar 11, 2023

Where we drop the go compiler in the second example? Can you describe this?

1
·
·1 reply
Arsham Arya
Arsham Arya
Author
·Mar 11, 2023

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.

·
Akbarshoh Ismoilov
Akbarshoh Ismoilov
Mar 13, 2023

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

·
·2 replies
Arsham Arya
Arsham Arya
Author
·Mar 13, 2023

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)

1
·
Akbarshoh Ismoilov
Akbarshoh Ismoilov
Mar 13, 2023

Arsham Arya aha I catch you now. It is very interesting to learn

1
·