imulab / go-scim

Building blocks for servers implementing Simple Cloud Identity Management v2
MIT License
145 stars 56 forks source link

Docker build does not use cache for dependency downloading #84

Open aliotta opened 3 years ago

aliotta commented 3 years ago

The way the dockerfile is currently written doesn't leverage caching because the download deps step is run in the same context as the build binary step. Using the below dockerfile will improve dev experience.

` ##########################################################################

GO BUILDER

########################################################################## FROM golang:1.13-buster AS builder

WORKDIR /build/scim COPY go.mod ./ COPY pkg/v2/go.mod ./pkg/v2/go.mod COPY mongo/v2/go.mod ./mongo/v2/go.mod COPY Makefile ./ RUN make deps

COPY . ./ RUN make binary

##########################################################################

FINAL IMAGE

########################################################################## FROM debian:buster-slim

copy binary

COPY --from=builder /build/scim/bin/linux_amd64/scim /usr/bin/scim

copy public files

COPY --from=builder /build/scim/public /usr/share/scim/public

run

CMD ["/usr/bin/scim"] `

imulab commented 3 years ago

Good point @aliotta. I will make sure to incorporate this change into the next release. It may take a while, as I am still recovering from hospital. If you are up for it, feel free to create a PR.