Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
docker: add Dockerfile and .dockerignore
Browse files Browse the repository at this point in the history
Change-Id: I81b491e66a81c5b66c1561a9484434267e9b544d
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5140
Reviewed-by: Marcel van Lohuizen <[email protected]>
  • Loading branch information
zchee authored and mpvl committed Mar 5, 2020
1 parent 9b1dff7 commit d64abbe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*
*/

# not ignore go and cue files
!cmd/
!cue/
!cuego/
!encoding/
!internal/
!pkg/
!tools/

# not ignore go module files
!go.mod
!go.sum
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# target: cue-builder
ARG GOLANG_VERSION
FROM docker.io/golang:${GOLANG_VERSION}-alpine AS cue-builder
ARG CUE_VERSION
ENV \
OUTDIR='/out' \
GO111MODULE='on'
RUN set -eux && \
apk add --no-cache \
git
WORKDIR /go/src/cuelang.org/go
COPY go.mod /go/src/cuelang.org/go/
COPY go.sum /go/src/cuelang.org/go/
RUN set -eux && \
go mod download
COPY . /go/src/cuelang.org/go/
RUN set -eux && \
CGO_ENABLED=0 GOBIN=${OUTDIR}/usr/bin/ go install \
-a -v \
-tags='osusergo,netgo' \
-installsuffix='netgo' \
-ldflags="-s -w -X cuelang.org/go/cmd/cue/cmd.version=${CUE_VERSION} \"-extldflags=-static\"" \
./cmd/cue

# target: cue
FROM gcr.io/distroless/static:latest AS cue
COPY --from=cue-builder /out/ /
ENTRYPOINT ["/usr/bin/cue"]

0 comments on commit d64abbe

Please sign in to comment.