allow 'make dev-docker' to cache resolved modules (#5588)
This commit is contained in:
parent
5cd32d0a9e
commit
3364638e4d
|
@ -7,10 +7,26 @@ ARG GIT_DESCRIBE
|
|||
# WORKDIR /go/src/github.com/hashicorp/consul
|
||||
ENV CONSUL_DEV=1
|
||||
ENV COLORIZE=0
|
||||
Add . /go/src/github.com/hashicorp/consul/
|
||||
RUN make dev
|
||||
|
||||
# Cache modules separately from more frequently edited source files.
|
||||
#
|
||||
# The trick is taken from [https://medium.com/@pliutau/docker-and-go-modules-4265894f9fc#6622]
|
||||
#
|
||||
# We copy the modules files in first since they are less likely to change frequently
|
||||
# and the population of the go mod cache will be invalidated less frequently.
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN mkdir -p api sdk
|
||||
COPY api/go.mod api
|
||||
COPY api/go.sum api
|
||||
COPY sdk/go.mod sdk
|
||||
COPY sdk/go.sum sdk
|
||||
RUN go mod download
|
||||
|
||||
# Add the rest of the code.
|
||||
ADD . /consul/
|
||||
RUN make dev
|
||||
|
||||
FROM consul:latest
|
||||
|
||||
COPY --from=builder /go/src/github.com/hashicorp/consul/bin/consul /bin
|
||||
COPY --from=builder /go/bin/consul /bin
|
||||
|
|
Loading…
Reference in New Issue