git.iko.soy/typeable/oauth2-proxy
on master help sign in
Reduce docker context to improve build times
commit7ffe9b76203c0bb6c9aa4f06e6fd1e36a7e05ffb authorJoel Speed <joel.speed@hotmail.co.uk> dateTue 7 Jul 2020, 09:53 (6 years ago) parenta999270
6 files changed+22−12
.dockerignore+4 CHANGELOG.md+1 Dockerfile+2−1 Dockerfile.arm64+2−1 Dockerfile.armv6+2−1 Makefile+11−9
.dockerignore+4
@@ -1 +1,5 @@
11Dockerfile.dev
2+docs
3+vendor
4+.git
5+oauth2-proxy
CHANGELOG.md+1
@@ -8,6 +8,7 @@
88
99## Changes since v6.0.0
1010
11+- [#669](https://github.com/oauth2-proxy/oauth2-proxy/pull/669) Reduce docker context to improve build times (@JoelSpeed)
1112- [#668](https://github.com/oauth2-proxy/oauth2-proxy/pull/668) Use req.Host in --force-https when req.URL.Host is empty (@zucaritask)
1213- [#660](https://github.com/oauth2-proxy/oauth2-proxy/pull/660) Use builder pattern to simplify requests to external endpoints (@JoelSpeed)
1314- [#591](https://github.com/oauth2-proxy/oauth2-proxy/pull/591) Introduce upstream package with new reverse proxy implementation (@JoelSpeed)
Dockerfile+2−1
@@ -1,4 +1,5 @@
11FROM golang:1.14-buster AS builder
2+ARG VERSION
23
34# Download tools
45RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
@@ -19,7 +20,7 @@ COPY . .
1920# build the key into the container and then tell it where it is
2021# by setting OAUTH2_PROXY_JWT_KEY_FILE=/etc/ssl/private/jwt_signing_key.pem
2122# in app.yaml instead.
22−RUN make build && touch jwt_signing_key.pem
23+RUN VERSION=${VERSION} make build && touch jwt_signing_key.pem
2324
2425# Copy binary to alpine
2526FROM alpine:3.11
Dockerfile.arm64+2−1
@@ -1,4 +1,5 @@
11FROM golang:1.14-buster AS builder
2+ARG VERSION
23
34# Download tools
45RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
@@ -19,7 +20,7 @@ COPY . .
1920# build the key into the container and then tell it where it is
2021# by setting OAUTH2_PROXY_JWT_KEY_FILE=/etc/ssl/private/jwt_signing_key.pem
2122# in app.yaml instead.
22−RUN GOARCH=arm64 make build && touch jwt_signing_key.pem
23+RUN VERSION=${VERSION} GOARCH=arm64 make build && touch jwt_signing_key.pem
2324
2425# Copy binary to alpine
2526FROM arm64v8/alpine:3.11
Dockerfile.armv6+2−1
@@ -1,4 +1,5 @@
11FROM golang:1.14-buster AS builder
2+ARG VERSION
23
34# Download tools
45RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
@@ -19,7 +20,7 @@ COPY . .
1920# build the key into the container and then tell it where it is
2021# by setting OAUTH2_PROXY_JWT_KEY_FILE=/etc/ssl/private/jwt_signing_key.pem
2122# in app.yaml instead.
22−RUN GOARCH=arm GOARM=6 make build && touch jwt_signing_key.pem
23+RUN VERSION=${VERSION} GOARCH=arm GOARM=6 make build && touch jwt_signing_key.pem
2324
2425# Copy binary to alpine
2526FROM arm32v6/alpine:3.11
Makefile+11−9
@@ -2,7 +2,7 @@ GO ?= go
22GOLANGCILINT ?= golangci-lint
33
44BINARY := oauth2-proxy
5−VERSION := $(shell git describe --always --dirty --tags 2>/dev/null || echo "undefined")
5+VERSION ?= $(shell git describe --always --dirty --tags 2>/dev/null || echo "undefined")
66# Allow to override image registry.
77REGISTRY ?= quay.io/oauth2-proxy
88.NOTPARALLEL:
@@ -13,6 +13,8 @@ MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1
1313MINIMUM_SUPPORTED_GO_MINOR_VERSION = 14
1414GO_VERSION_VALIDATION_ERR_MSG = Golang version is not supported, please update to at least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION)
1515
16+DOCKER_BUILD := docker build --build-arg VERSION=${VERSION}
17+
1618ifeq ($(COVER),true)
1719TESTCOVER ?= -coverprofile c.out
1820endif
@@ -41,17 +43,17 @@ $(BINARY):
4143
4244.PHONY: docker
4345docker:
44− docker build -f Dockerfile -t $(REGISTRY)/oauth2-proxy:latest .
46+ $(DOCKER_BUILD) -f Dockerfile -t $(REGISTRY)/oauth2-proxy:latest .
4547
4648.PHONY: docker-all
4749docker-all: docker
48− docker build -f Dockerfile -t $(REGISTRY)/oauth2-proxy:latest-amd64 .
49− docker build -f Dockerfile -t $(REGISTRY)/oauth2-proxy:${VERSION} .
50− docker build -f Dockerfile -t $(REGISTRY)/oauth2-proxy:${VERSION}-amd64 .
51− docker build -f Dockerfile.arm64 -t $(REGISTRY)/oauth2-proxy:latest-arm64 .
52− docker build -f Dockerfile.arm64 -t $(REGISTRY)/oauth2-proxy:${VERSION}-arm64 .
53− docker build -f Dockerfile.armv6 -t $(REGISTRY)/oauth2-proxy:latest-armv6 .
54− docker build -f Dockerfile.armv6 -t $(REGISTRY)/oauth2-proxy:${VERSION}-armv6 .
50+ $(DOCKER_BUILD) -f Dockerfile -t $(REGISTRY)/oauth2-proxy:latest-amd64 .
51+ $(DOCKER_BUILD) -f Dockerfile -t $(REGISTRY)/oauth2-proxy:${VERSION} .
52+ $(DOCKER_BUILD) -f Dockerfile -t $(REGISTRY)/oauth2-proxy:${VERSION}-amd64 .
53+ $(DOCKER_BUILD) -f Dockerfile.arm64 -t $(REGISTRY)/oauth2-proxy:latest-arm64 .
54+ $(DOCKER_BUILD) -f Dockerfile.arm64 -t $(REGISTRY)/oauth2-proxy:${VERSION}-arm64 .
55+ $(DOCKER_BUILD) -f Dockerfile.armv6 -t $(REGISTRY)/oauth2-proxy:latest-armv6 .
56+ $(DOCKER_BUILD) -f Dockerfile.armv6 -t $(REGISTRY)/oauth2-proxy:${VERSION}-armv6 .
5557
5658.PHONY: docker-push
5759docker-push: