git.iko.soy/typeable/oauth2-proxy
on master help sign in
Docker build optimization
cb41a91YAEGASHI Takeshi
Dockerfile+12−8
@@ -1,18 +1,22 @@
1FROM golang:1.11-stretch AS builder
1FROM golang:1.11-stretch AS builder
2+
3+# Download tools
4+RUN wget -O $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64
5+RUN chmod +x $GOPATH/bin/dep
6+
7+# Copy sources
2−WORKDIR /go/src/github.com/pusher/oauth2_proxy
8+WORKDIR $GOPATH/src/github.com/pusher/oauth2_proxy
3COPY . .
9COPY . .
4
10
5# Fetch dependencies
11# Fetch dependencies
6−RUN wget -O dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64
7−RUN chmod +x dep
8−RUN mv dep $GOPATH/bin/dep
9RUN dep ensure --vendor-only
12RUN dep ensure --vendor-only
10
13
11−# Build image
14+# Build binary
12−RUN ./configure && make clean oauth2_proxy
15+RUN ./configure && make build
13
16
14−# Copy binary to debian
17+# Copy binary to alpine
15−FROM debian:stretch
18+FROM alpine:3.8
19+RUN apk add --no-cache ca-certificates
16COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy
20COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy
17
21
18ENTRYPOINT ["/bin/oauth2_proxy"]
22ENTRYPOINT ["/bin/oauth2_proxy"]