'Multi Staging Docker Image for production use

I have a multi staging golang image that I want to use for production and development the docker file is something like this

FROM  golang:1.16 AS Development


RUN mkdir /project
ADD . /project
WORKDIR /project

RUN CGO_ENABLED=0 GOOS=linux go build  -o main ./...

FROM scratch AS production
COPY --from=development /project .
CMD ["./main"]

when i build with docker

docker build -t myApp .

and run docker images -> i see the 2 images created are there an option to provide docker to create only the second image or the first image ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source