mirror of https://github.com/hashicorp/consul
Browse Source
* Docker based builds can now use the module cache * Simplify building the consul-dev docker image. * Make sure to pull the latest consul image. * Allow selecting base image version for the dev imagepull/5662/head
Matt Keeler
6 years ago
committed by
GitHub
4 changed files with 71 additions and 40 deletions
@ -1,32 +1,3 @@
|
||||
ARG CONSUL_BUILD_IMAGE |
||||
FROM ${CONSUL_BUILD_IMAGE}:latest as builder |
||||
# FROM golang:latest as builder |
||||
ARG GIT_COMMIT |
||||
ARG GIT_DIRTY |
||||
ARG GIT_DESCRIBE |
||||
# WORKDIR /go/src/github.com/hashicorp/consul |
||||
ENV CONSUL_DEV=1 |
||||
ENV COLORIZE=0 |
||||
|
||||
# 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/bin/consul /bin |
||||
ARG CONSUL_IMAGE_VERSION=latest |
||||
FROM consul:${CONSUL_IMAGE_VERSION} |
||||
COPY consul /go |
||||
|
Loading…
Reference in new issue