comments powered by Disqus
I recently ran into an issue with building my Go app in one container and then running it in another one. I do this to make my container image smaller.
CGO_ENABLED=0, in a multi-stage build, it will say something like the
exec /app/main: no such file or directory.
FROM golang:1.16 AS builder
COPY main.go go.mod go.sum /src/
RUN go get
# Without `CGO_ENABLED=0`, in a multi-stage build, it will say something like
# exec /app/main: no such file or directory
RUN CGO_ENABLED=0 go build -o /src/main /src/main.go
COPY --from=builder /src/main /app/main
COPY index.html /app/
ENTRYPOINT [ "/app/main" ]