From f289543dc6820ef81ea232f53f0ba9698d2e46c6 Mon Sep 17 00:00:00 2001 From: Karl Skewes Date: Sat, 2 Feb 2019 14:20:20 +1300 Subject: [PATCH] fix(docker): simplify build by copying ca-certificates.crt --- .travis.yml | 3 --- BUILDING.md | 52 ------------------------------------------------ CONTRIBUTING.md | 1 - Dockerfile | 2 +- Dockerfile.arm64 | 4 +--- Dockerfile.armv6 | 4 +--- Makefile | 16 +-------------- README.md | 2 -- 8 files changed, 4 insertions(+), 80 deletions(-) delete mode 100644 BUILDING.md diff --git a/.travis.yml b/.travis.yml index d50b3da..f939d99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,6 @@ language: go go: - 1.10.x - 1.11.x -before_install: - - sudo apt-get install -y qemu-user-static - - sudo docker run --rm --privileged multiarch/qemu-user-static:register install: # Fetch dependencies - wget -O dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 diff --git a/BUILDING.md b/BUILDING.md deleted file mode 100644 index 267f471..0000000 --- a/BUILDING.md +++ /dev/null @@ -1,52 +0,0 @@ -# Building - -This project is setup to build on amd64. - -It is also possible to cross build binaries and docker images for armv6 and arm64. - -## Clone repo and configure - -```bash -cd $GOPATH/src/github.com # Create this directory if it doesn't exist -git clone git@github.com:/oauth2_proxy pusher/oauth2_proxy -cd pusher/oauth2_proxy -./configure # Setup your environment variables -make dep -``` - -## Building amd64 - -Build binary: -```bash -make -``` - -Build docker image: -```bash -make docker -``` - -## Building for other architectures - -This requires [multiarch/qemu-user-static](https://github.com/multiarch/qemu-user-static) to be installed in your system. -On Ubuntu: -```bash -sudo apt install qemu-user-static -``` - -Register `qemu-user-static` on your system: -```bash -# make qemu-register -# or -sudo docker run --rm --privileged multiarch/qemu-user-static:register -``` - -Build all binaries: -```bash -make release -``` - -Build all docker images: -```bash -make docker-all -``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe34e17..6b8c3a5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,6 @@ To develop on this project, please fork the repo and clone into your `$GOPATH`. Dependencies are **not** checked in so please download those separately. Download the dependencies using [`dep`](https://github.com/golang/dep). - ```bash cd $GOPATH/src/github.com # Create this directory if it doesn't exist git clone git@github.com:/oauth2_proxy pusher/oauth2_proxy diff --git a/Dockerfile b/Dockerfile index 487d29b..126ce40 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ RUN ./configure && make build # Copy binary to alpine FROM alpine:3.8 -RUN apk add --no-cache ca-certificates +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy ENTRYPOINT ["/bin/oauth2_proxy"] diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 253077f..4a8dc7d 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -16,9 +16,7 @@ RUN ./configure && GOARCH=arm64 make build # Copy binary to alpine FROM arm64v8/alpine:3.8 -COPY dist/qemu-aarch64-static /usr/bin/ -RUN apk add --no-cache ca-certificates +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy -RUN rm /usr/bin/qemu-*-static -f ENTRYPOINT ["/bin/oauth2_proxy"] diff --git a/Dockerfile.armv6 b/Dockerfile.armv6 index 1daa4c4..5f7f7af 100644 --- a/Dockerfile.armv6 +++ b/Dockerfile.armv6 @@ -16,9 +16,7 @@ RUN ./configure && GOARCH=arm GOARM=6 make build # Copy binary to alpine FROM arm32v6/alpine:3.8 -COPY dist/qemu-arm-static /usr/bin/ -RUN apk add --no-cache ca-certificates +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /go/src/github.com/pusher/oauth2_proxy/oauth2_proxy /bin/oauth2_proxy -RUN rm /usr/bin/qemu-*-static -f ENTRYPOINT ["/bin/oauth2_proxy"] diff --git a/Makefile b/Makefile index 8d388cf..a5c4514 100644 --- a/Makefile +++ b/Makefile @@ -45,26 +45,12 @@ build: clean $(BINARY) $(BINARY): CGO_ENABLED=0 $(GO) build -a -installsuffix cgo -ldflags="-X main.VERSION=${VERSION}" -o $@ github.com/pusher/oauth2_proxy -# Ubuntu 18.04.1 Qemu version -QEMU-STATIC-VERSION=v2.11.1 - -.PHONY: qemu-static -qemu-static: - wget -O dist/qemu-amd64-static https://github.com/multiarch/qemu-user-static/releases/download/${QEMU-STATIC-VERSION}/qemu-x86_64-static - wget -O dist/qemu-aarch64-static https://github.com/multiarch/qemu-user-static/releases/download/${QEMU-STATIC-VERSION}/qemu-aarch64-static - wget -O dist/qemu-arm-static https://github.com/multiarch/qemu-user-static/releases/download/${QEMU-STATIC-VERSION}/qemu-arm-static - chmod +x dist/qemu-*-static - -.PHONY: qemu-register -qemu-register: - docker run --rm --privileged multiarch/qemu-user-static:register - .PHONY: docker docker: docker build -f Dockerfile -t pusher/oauth2_proxy:latest . .PHONY: docker-all -docker-all: qemu-static docker +docker-all: docker docker build -f Dockerfile -t pusher/oauth2_proxy:latest-amd64 . docker build -f Dockerfile -t pusher/oauth2_proxy:${VERSION} . docker build -f Dockerfile -t pusher/oauth2_proxy:${VERSION}-amd64 . diff --git a/README.md b/README.md index 827b046..910a671 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,6 @@ A list of changes can be seen in the [CHANGELOG](CHANGELOG.md). c. Using the prebuilt docker image [quay.io/pusher/oauth2_proxy](https://quay.io/pusher/oauth2_proxy) - d. Building from scratch following our [Building](BUILDING.md) guide - Prebuilt binaries can be validated by extracting the file and verifying it against the `sha256sum.txt` checksum file provided for each release starting with version `v3.0.0`. ```