mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2024-11-28 09:08:44 +02:00
Merge pull request #1391 from oauth2-proxy/docker-buildx-selection
Improve build times by sharing cache and allowing platform selection
This commit is contained in:
commit
85c02821bf
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
## Changes since v7.1.3
|
## Changes since v7.1.3
|
||||||
|
|
||||||
|
- [#1391](https://github.com/oauth2-proxy/oauth2-proxy/pull/1391) Improve build times by sharing cache and allowing platform selection (@JoelSpeed)
|
||||||
- [#1404](https://github.com/oauth2-proxy/oauth2-proxy/pull/1404) Improve error message when no cookie is found (@JoelSpeed)
|
- [#1404](https://github.com/oauth2-proxy/oauth2-proxy/pull/1404) Improve error message when no cookie is found (@JoelSpeed)
|
||||||
- [#1315](https://github.com/oauth2-proxy/oauth2-proxy/pull/1315) linkedin: Update provider to v2 (@wuurrd)
|
- [#1315](https://github.com/oauth2-proxy/oauth2-proxy/pull/1315) linkedin: Update provider to v2 (@wuurrd)
|
||||||
- [#1348](https://github.com/oauth2-proxy/oauth2-proxy/pull/1348) Using the native httputil proxy code for websockets rather than yhat/wsutil to properly handle HTTP-level failures (@thetrime)
|
- [#1348](https://github.com/oauth2-proxy/oauth2-proxy/pull/1348) Using the native httputil proxy code for websockets rather than yhat/wsutil to properly handle HTTP-level failures (@thetrime)
|
||||||
|
22
Dockerfile
22
Dockerfile
@ -1,16 +1,24 @@
|
|||||||
FROM golang:1.16-buster AS builder
|
# All builds should be done using the platform native to the build node to allow
|
||||||
|
# cache sharing of the go mod download step.
|
||||||
|
# Go cross compilation is also faster than emulation the go compilation across
|
||||||
|
# multiple platforms.
|
||||||
|
FROM --platform=${BUILDPLATFORM} golang:1.16-buster AS builder
|
||||||
|
|
||||||
# Copy sources
|
# Copy sources
|
||||||
WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy
|
WORKDIR $GOPATH/src/github.com/oauth2-proxy/oauth2-proxy
|
||||||
|
|
||||||
# Fetch dependencies
|
# Fetch dependencies
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN GO111MODULE=on go mod download
|
RUN go mod download
|
||||||
|
|
||||||
# Now pull in our code
|
# Now pull in our code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Arguments go here so that the previous steps can be cached if no external
|
||||||
|
# sources have changed.
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
ARG BUILDPLATFORM
|
||||||
|
|
||||||
# Build binary and make sure there is at least an empty key file.
|
# Build binary and make sure there is at least an empty key file.
|
||||||
# This is useful for GCP App Engine custom runtime builds, because
|
# This is useful for GCP App Engine custom runtime builds, because
|
||||||
@ -18,7 +26,15 @@ ARG VERSION
|
|||||||
# build the key into the container and then tell it where it is
|
# build the key into the container and then tell it where it is
|
||||||
# by setting OAUTH2_PROXY_JWT_KEY_FILE=/etc/ssl/private/jwt_signing_key.pem
|
# by setting OAUTH2_PROXY_JWT_KEY_FILE=/etc/ssl/private/jwt_signing_key.pem
|
||||||
# in app.yaml instead.
|
# in app.yaml instead.
|
||||||
RUN VERSION=${VERSION} make build && touch jwt_signing_key.pem
|
# Set the cross compilation arguments based on the TARGETPLATFORM which is
|
||||||
|
# automatically set by the docker engine.
|
||||||
|
RUN case ${TARGETPLATFORM} in \
|
||||||
|
"linux/amd64") GOARCH=amd64 ;; \
|
||||||
|
"linux/arm64") GOARCH=arm64 ;; \
|
||||||
|
"linux/arm/v6") GOARCH=arm GOARM=6 ;; \
|
||||||
|
esac && \
|
||||||
|
printf "Building OAuth2 Proxy for arch ${GOARCH}\n" && \
|
||||||
|
VERSION=${VERSION} make build && touch jwt_signing_key.pem
|
||||||
|
|
||||||
# Copy binary to alpine
|
# Copy binary to alpine
|
||||||
FROM alpine:3.14
|
FROM alpine:3.14
|
||||||
|
12
Makefile
12
Makefile
@ -22,8 +22,8 @@ all: lint $(BINARY)
|
|||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf release
|
-rm -rf release
|
||||||
rm -f $(BINARY)
|
-rm -f $(BINARY)
|
||||||
|
|
||||||
.PHONY: distclean
|
.PHONY: distclean
|
||||||
distclean: clean
|
distclean: clean
|
||||||
@ -37,10 +37,12 @@ lint: validate-go-version
|
|||||||
build: validate-go-version clean $(BINARY)
|
build: validate-go-version clean $(BINARY)
|
||||||
|
|
||||||
$(BINARY):
|
$(BINARY):
|
||||||
GO111MODULE=on CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X main.VERSION=${VERSION}" -o $@ github.com/oauth2-proxy/oauth2-proxy/v7
|
CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X main.VERSION=${VERSION}" -o $@ github.com/oauth2-proxy/oauth2-proxy/v7
|
||||||
|
|
||||||
|
DOCKER_BUILD_PLATFORM ?= linux/amd64,linux/arm64,linux/arm/v6
|
||||||
|
DOCKER_BUILDX_ARGS ?=
|
||||||
DOCKER_BUILD := docker build --build-arg VERSION=${VERSION}
|
DOCKER_BUILD := docker build --build-arg VERSION=${VERSION}
|
||||||
DOCKER_BUILDX := docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v6 --build-arg VERSION=${VERSION}
|
DOCKER_BUILDX := docker buildx build ${DOCKER_BUILDX_ARGS} --platform ${DOCKER_BUILD_PLATFORM} --build-arg VERSION=${VERSION}
|
||||||
|
|
||||||
.PHONY: docker
|
.PHONY: docker
|
||||||
docker:
|
docker:
|
||||||
@ -58,7 +60,7 @@ docker-all: docker
|
|||||||
|
|
||||||
.PHONY: docker-push
|
.PHONY: docker-push
|
||||||
docker-push:
|
docker-push:
|
||||||
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v6 -t $(REGISTRY)/oauth2-proxy:latest .
|
docker buildx build --push --platform ${DOCKER_BUILD_PLATFORM} -t $(REGISTRY)/oauth2-proxy:latest .
|
||||||
|
|
||||||
.PHONY: docker-push-all
|
.PHONY: docker-push-all
|
||||||
docker-push-all: docker-push
|
docker-push-all: docker-push
|
||||||
|
Loading…
Reference in New Issue
Block a user