From 02899944a9b5a4ae0c8f28d386e1ae3316fbf375 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Fri, 7 Jun 2019 16:15:50 -0700 Subject: [PATCH] Try to speed up build --- .drone.yml | 227 +++++++++++++++++++++++++++++------------------------ Dockerfile | 29 +++---- Makefile | 12 +++ 3 files changed, 151 insertions(+), 117 deletions(-) diff --git a/.drone.yml b/.drone.yml index 914c145..0833306 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,62 +8,24 @@ steps: - name: build image: golang:1.11 commands: - - go version - - go env - go get -u github.com/golang/dep/cmd/dep - - make build + - make build-all-static ---- -kind: pipeline -name: linux-amd64 - -depends_on: - - test - -trigger: - event: - - push - - tag - refs: - - refs/heads/master - - refs/tags/v* - -steps: - - - name: build + - name: push amd64 image image: plugins/docker settings: repo: iamthefij/dockron - auto_tag: true - auto_tag_suffix: linux-amd64 + tag: linux-amd64 username: from_secret: docker_username password: from_secret: docker_password ---- -kind: pipeline -name: linux-arm - -depends_on: - - test - -trigger: - event: - - push - - tag - refs: - - refs/heads/master - - refs/tags/v* - -steps: - - - name: build + - name: push arm image image: plugins/docker settings: repo: iamthefij/dockron - auto_tag: true - auto_tag_suffix: linux-arm + tag: linux-arm username: from_secret: docker_username password: @@ -72,63 +34,122 @@ steps: - ARCH=arm - REPO=arm32v6 ---- -kind: pipeline -name: linux-arm64 - -depends_on: - - test - -trigger: - event: - - push - - tag - refs: - - refs/heads/master - - refs/tags/v* - -steps: - - - name: build - image: plugins/docker - settings: - repo: iamthefij/dockron - auto_tag: true - auto_tag_suffix: linux-arm64 - username: - from_secret: docker_username - password: - from_secret: docker_password - build_args: - - ARCH=arm64 - - REPO=arm64v8 - ---- -kind: pipeline -name: manifest - -depends_on: - - linux-amd64 - - linux-arm - - linux-arm64 - -trigger: - event: - - push - - tag - ref: - - refs/heads/master - - refs/tags/v* - -steps: - - name: publish manifest - image: plugins/manifest - settings: - spec: manifest.tmpl - auto_tag: true - ignore_missing: true - username: - from_secret: docker_username - password: - from_secret: docker_password - +# --- +# kind: pipeline +# name: linux-amd64 +# +# depends_on: +# - test +# +# trigger: +# event: +# - push +# - tag +# refs: +# - refs/heads/master +# - refs/tags/v* +# +# steps: +# +# - name: build +# image: plugins/docker +# settings: +# repo: iamthefij/dockron +# auto_tag: true +# auto_tag_suffix: linux-amd64 +# username: +# from_secret: docker_username +# password: +# from_secret: docker_password +# +# --- +# kind: pipeline +# name: linux-arm +# +# depends_on: +# - test +# +# trigger: +# event: +# - push +# - tag +# refs: +# - refs/heads/master +# - refs/tags/v* +# +# steps: +# +# - name: build +# image: plugins/docker +# settings: +# repo: iamthefij/dockron +# auto_tag: true +# auto_tag_suffix: linux-arm +# username: +# from_secret: docker_username +# password: +# from_secret: docker_password +# build_args: +# - ARCH=arm +# - REPO=arm32v6 +# +# --- +# kind: pipeline +# name: linux-arm64 +# +# depends_on: +# - test +# +# trigger: +# event: +# - push +# - tag +# refs: +# - refs/heads/master +# - refs/tags/v* +# +# steps: +# +# - name: build +# image: plugins/docker +# settings: +# repo: iamthefij/dockron +# auto_tag: true +# auto_tag_suffix: linux-arm64 +# username: +# from_secret: docker_username +# password: +# from_secret: docker_password +# build_args: +# - ARCH=arm64 +# - REPO=arm64v8 +# +# --- +# kind: pipeline +# name: manifest +# +# depends_on: +# - linux-amd64 +# - linux-arm +# - linux-arm64 +# +# trigger: +# event: +# - push +# - tag +# ref: +# - refs/heads/master +# - refs/tags/v* +# +# steps: +# - name: publish manifest +# image: plugins/manifest +# settings: +# spec: manifest.tmpl +# auto_tag: true +# ignore_missing: true +# username: +# from_secret: docker_username +# password: +# from_secret: docker_password +# diff --git a/Dockerfile b/Dockerfile index 6acbcac..46a5967 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,21 @@ ARG REPO=library -FROM golang:1.11-alpine AS builder - -RUN apk add --no-cache git -RUN go get -u github.com/golang/dep/cmd/dep - -WORKDIR /go/src/app/ -COPY ./Gopkg.* /go/src/app/ -RUN dep ensure --vendor-only - -COPY ./main.go /go/src/app/ - -ARG ARCH=amd64 -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -a -installsuffix nocgo -o dockron . +# FROM golang:1.11-alpine AS builder +# +# RUN apk add --no-cache git +# RUN go get -u github.com/golang/dep/cmd/dep +# +# WORKDIR /go/src/app/ +# COPY ./Gopkg.* /go/src/app/ +# RUN dep ensure --vendor-only +# +# COPY ./main.go /go/src/app/ +# +# RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -a -installsuffix nocgo -o dockron . FROM ${REPO}/busybox:latest WORKDIR /root/ -COPY --from=builder /go/src/app/dockron . +# COPY --from=builder /go/src/app/dockron . +ARG ARCH=amd64 +COPY ./dockron-linux-${ARCH} . CMD [ "./dockron" ] diff --git a/Makefile b/Makefile index b51510c..5c9bd9e 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,18 @@ dockron: vendor .PHONY: build build: dockron +dockron-linux-amd64: vendor + GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o dockron-linux-amd64 + +dockron-linux-arm: vendor + GOARCH=arm CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o dockron-linux-arm + +dockron-linux-arm64: vendor + GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o dockron-linux-arm64 + +.PHONY: build-all-static +build-all-static: dockron-linux-amd64 dockron-linux-arm dockron-linux-arm64 + # Cleans all build artifacts .PHONY: clean clean: