mirror of
https://github.com/stefanprodan/podinfo.git
synced 2026-03-04 19:10:26 +00:00
Add multi-build Docker file for GCR CI
This commit is contained in:
32
Dockerfile.ci
Normal file
32
Dockerfile.ci
Normal file
@@ -0,0 +1,32 @@
|
||||
FROM golang:1.9 as builder
|
||||
|
||||
RUN mkdir -p /go/src/github.com/stefanprodan/k8s-podinfo/
|
||||
|
||||
WORKDIR /go/src/github.com/stefanprodan/k8s-podinfo
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN go test $(go list ./... | grep -v integration | grep -v /vendor/ | grep -v /template/) -cover
|
||||
|
||||
RUN gofmt -l -d $(find . -type f -name '*.go' -not -path "./vendor/*") && \
|
||||
GIT_COMMIT=$(git rev-list -1 HEAD) && \
|
||||
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w \
|
||||
-X github.com/stefanprodan/k8s-podinfo/pkg/version.GITCOMMIT=${GIT_COMMIT}" \
|
||||
-a -installsuffix cgo -o podinfo ./cmd/podinfo
|
||||
|
||||
FROM alpine:3.7
|
||||
|
||||
RUN addgroup -S app \
|
||||
&& adduser -S -g app app \
|
||||
&& apk --no-cache add \
|
||||
curl openssl netcat-openbsd
|
||||
|
||||
WORKDIR /home/app
|
||||
|
||||
COPY --from=builder /go/src/github.com/stefanprodan/k8s-podinfo/podinfo .
|
||||
|
||||
RUN chown -R app:app ./
|
||||
|
||||
USER app
|
||||
|
||||
CMD ["./podinfo"]
|
||||
Reference in New Issue
Block a user