git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #21 from yaegashi/docker-improvement

Docker improvement

commitc922a09ee7a67ef070bda0be872d7893e3a20c75 authorJoel Speed <Joel.speed@hotmail.co.uk> dateMon 21 Jan 2019, 18:08 (8 years ago) parent4731122ccaa6e9
4 files changed+21−9
.dockerignore+1 .gitignore+7 Dockerfile+12−8 Makefile+1−1
.dockerignorenew file+1
@@ -0,0 +1 @@
1+Dockerfile.dev
.gitignore+7
@@ -29,3 +29,10 @@ _testmain.go
2929
3030# Editor swap/temp files
3131.*.swp
32+
33+# Dockerfile.dev is ignored by both git and docker
34+# for faster development cycle of docker build
35+# cp Dockerfile Dockerfile.dev
36+# vi Dockerfile.dev
37+# docker build -f Dockerfile.dev .
38+Dockerfile.dev
Dockerfile+12−8
@@ -1,18 +1,22 @@
11FROM golang:1.11-stretch AS builder
2−WORKDIR /go/src/github.com/pusher/oauth2_proxy
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
8+WORKDIR $GOPATH/src/github.com/pusher/oauth2_proxy
39COPY . .
410
511# 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
912RUN dep ensure --vendor-only
1013
11−# Build image
12−RUN ./configure && make clean oauth2_proxy
14+# Build binary
15+RUN ./configure && make build
1316
14−# Copy binary to debian
15−FROM debian:stretch
17+# Copy binary to alpine
18+FROM alpine:3.8
19+RUN apk add --no-cache ca-certificates
1620COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy
1721
1822ENTRYPOINT ["/bin/oauth2_proxy"]
Makefile+1−1
@@ -43,7 +43,7 @@ dep:
4343build: clean $(BINARY)
4444
4545$(BINARY):
46− $(GO) build -ldflags="-X main.VERSION=${VERSION}" -o $(BINARY) github.com/pusher/oauth2_proxy
46+ CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X main.VERSION=${VERSION}" -o $@ github.com/pusher/oauth2_proxy
4747
4848.PHONY: test
4949test: dep lint