Koichi Shiraishi | d64abbe | 2020-03-03 02:28:19 +0900 | [diff] [blame] | 1 | # target: cue-builder |
| 2 | ARG GOLANG_VERSION |
| 3 | FROM docker.io/golang:${GOLANG_VERSION}-alpine AS cue-builder |
| 4 | ARG CUE_VERSION |
| 5 | ENV \ |
| 6 | OUTDIR='/out' \ |
| 7 | GO111MODULE='on' |
| 8 | RUN set -eux && \ |
| 9 | apk add --no-cache \ |
| 10 | git |
| 11 | WORKDIR /go/src/cuelang.org/go |
| 12 | COPY go.mod /go/src/cuelang.org/go/ |
| 13 | COPY go.sum /go/src/cuelang.org/go/ |
| 14 | RUN set -eux && \ |
| 15 | go mod download |
| 16 | COPY . /go/src/cuelang.org/go/ |
| 17 | RUN set -eux && \ |
| 18 | CGO_ENABLED=0 GOBIN=${OUTDIR}/usr/bin/ go install \ |
| 19 | -a -v \ |
| 20 | -tags='osusergo,netgo' \ |
| 21 | -installsuffix='netgo' \ |
| 22 | -ldflags="-s -w -X cuelang.org/go/cmd/cue/cmd.version=${CUE_VERSION} \"-extldflags=-static\"" \ |
| 23 | ./cmd/cue |
| 24 | |
| 25 | # target: cue |
| 26 | FROM gcr.io/distroless/static:latest AS cue |
| 27 | COPY --from=cue-builder /out/ / |
| 28 | ENTRYPOINT ["/usr/bin/cue"] |