I want to do a docker multi-stage build but rm/ignore the .git folder, to save space on the docker image.
FROM ubuntu as first
WORKDIR /app
RUN git clone <repo>
FROM golang as second
WORKDIR app
COPY --from=first /app .
is there is some --exclude option for COPY? Here is a related issue: https://forums.docker.com/t/dockerignore-in-multi-stage-builds/57169
another possibility is to remove the .git folder manually:
FROM ubuntu as first
WORKDIR /app
RUN git clone <repo>
RUN rm -rf .git
I assume the multi-stage build copies the "final layer" from the other stage?