git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #37 from kskewes/dockerarm

feat(arm): Cross build arm and arm64 docker images

commit92c4424639af03a73c6b77a9644db676c8bb227d authorJoel Speed <Joel.speed@hotmail.co.uk> dateMon 4 Feb 2019, 10:36 (8 years ago) parentfb13ee8f289543
7 files changed+63−1
.gitignore+1 CHANGELOG.md+1 CONTRIBUTING.md+2 Dockerfile+1−1 Dockerfile.arm64+22 Dockerfile.armv6+22 Makefile+14
.gitignore+1
@@ -1,6 +1,7 @@
11oauth2_proxy
22vendor
33dist
4+release
45.godeps
56*.exe
67.env
CHANGELOG.md+1
@@ -18,6 +18,7 @@
1818 - After a successful login, you will be redirected to your original URL rather than /
1919- [#35](https://github.com/pusher/oauth2_proxy/pull/35) arm and arm64 binary releases (@kskewes)
2020 - Add armv6 and arm64 to Makefile `release` target
21+- [#37](https://github.com/pusher/oauth2_proxy/pull/37) cross build arm and arm64 docker images (@kskewes)
2122
2223# v3.0.0
2324
CONTRIBUTING.md+2
@@ -8,6 +8,8 @@ Download the dependencies using [`dep`](https://github.com/golang/dep).
88```bash
99cd $GOPATH/src/github.com # Create this directory if it doesn't exist
1010git clone git@github.com:<YOUR_FORK>/oauth2_proxy pusher/oauth2_proxy
11+cd pusher/oauth2_proxy
12+./configure # Setup your environment variables
1113make dep
1214```
1315
Dockerfile+1−1
@@ -16,7 +16,7 @@ RUN ./configure && make build
1616
1717# Copy binary to alpine
1818FROM alpine:3.8
19−RUN apk add --no-cache ca-certificates
19+COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
2020COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy
2121
2222ENTRYPOINT ["/bin/oauth2_proxy"]
Dockerfile.arm64new file+22
@@ -0,0 +1,22 @@
1+FROM 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
8+WORKDIR $GOPATH/src/github.com/pusher/oauth2_proxy
9+COPY . .
10+
11+# Fetch dependencies
12+RUN dep ensure --vendor-only
13+
14+# Build binary
15+RUN ./configure && GOARCH=arm64 make build
16+
17+# Copy binary to alpine
18+FROM arm64v8/alpine:3.8
19+COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
20+COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy
21+
22+ENTRYPOINT ["/bin/oauth2_proxy"]
Dockerfile.armv6new file+22
@@ -0,0 +1,22 @@
1+FROM 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
8+WORKDIR $GOPATH/src/github.com/pusher/oauth2_proxy
9+COPY . .
10+
11+# Fetch dependencies
12+RUN dep ensure --vendor-only
13+
14+# Build binary
15+RUN ./configure && GOARCH=arm GOARM=6 make build
16+
17+# Copy binary to alpine
18+FROM arm32v6/alpine:3.8
19+COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
20+COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy
21+
22+ENTRYPOINT ["/bin/oauth2_proxy"]
Makefile+14
@@ -45,6 +45,20 @@ build: clean $(BINARY)
4545$(BINARY):
4646 CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X main.VERSION=${VERSION}" -o $@ github.com/pusher/oauth2_proxy
4747
48+.PHONY: docker
49+docker:
50+ docker build -f Dockerfile -t pusher/oauth2_proxy:latest .
51+
52+.PHONY: docker-all
53+docker-all: docker
54+ docker build -f Dockerfile -t pusher/oauth2_proxy:latest-amd64 .
55+ docker build -f Dockerfile -t pusher/oauth2_proxy:${VERSION} .
56+ docker build -f Dockerfile -t pusher/oauth2_proxy:${VERSION}-amd64 .
57+ docker build -f Dockerfile.arm64 -t pusher/oauth2_proxy:latest-arm64 .
58+ docker build -f Dockerfile.arm64 -t pusher/oauth2_proxy:${VERSION}-arm64 .
59+ docker build -f Dockerfile.armv6 -t pusher/oauth2_proxy:latest-armv6 .
60+ docker build -f Dockerfile.armv6 -t pusher/oauth2_proxy:${VERSION}-armv6 .
61+
4862.PHONY: test
4963test: dep lint
5064 $(GO) test -v -race $(go list ./... | grep -v /vendor/)