Skip to content

Commit

Permalink
Multi-arch build. Update goreleaser. Use Docker for goreleaser (#191)
Browse files Browse the repository at this point in the history
* do a multi-arch build and use goreleaser

* update dockerfile for goreleaser

* use moar resources

* fix homebrew

* update dockerfile
  • Loading branch information
Andrew Suderman authored Aug 19, 2021
1 parent 033af38 commit fb98229
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 65 deletions.
110 changes: 65 additions & 45 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
version: 2.1

orbs:
rok8s-scripts: fairwinds/rok8s-scripts@11
rok8s: fairwinds/rok8s-scripts@11

executors:
golang-exec:
docker:
- image: circleci/golang:1.16-buster

references:
install_goreleaser: &install_goreleaser
run:
name: Install GoReleaser
command: |
curl -fsSLo goreleaser.deb https://github.com/goreleaser/goreleaser/releases/download/v0.131.1/goreleaser_amd64.deb
echo "640790dcbfa864f26de4c26c2d491f293a64525c8c6641c5bbdec7136b38977e goreleaser.deb" | sha256sum -c -
sudo dpkg -i goreleaser.deb
rm goreleaser.deb
e2e_config: &e2e_config
command_runner_image: quay.io/reactiveops/ci-images:v11-buster
kind_node_image: "kindest/node:v1.18.0@sha256:0e20578828edd939d25eb98496a685c76c98d54084932f76069f886ec315d694"
Expand All @@ -31,7 +23,24 @@ references:
only: /.*/
tags:
ignore: /.*/

enable_experimental_features: &enable_experimental_docker_features
run:
name: enable experimental features
command: |
set -ex
apk --update add openssh
ssh remote-docker \<<EOF
sudo bash -c 'echo "{\"experimental\": true}" > /etc/docker/daemon.json'
sudo systemctl restart docker
EOF
install_vault: &install_vault
run:
name: install hashicorp vault
command: |
curl -LO https://releases.hashicorp.com/vault/1.8.1/vault_1.8.1_linux_amd64.zip
unzip vault_1.8.1_linux_amd64.zip
mv vault /usr/bin/vault
apk --update add yq
jobs:
test:
working_directory: /go/src/github.com/fairwindsops/pluto
Expand Down Expand Up @@ -63,19 +72,48 @@ jobs:
- save_cache:
key: v1-sonarcloud-scanner-4.1.0.1829
paths: /tmp/cache/scanner
release_binary:
release:
working_directory: /go/src/github.com/fairwindsops/pluto
resource_class: large
docker:
- image: circleci/golang:1.15
- image: goreleaser/goreleaser:v0.174.2
environment:
GO111MODULE: "on"
steps:
- checkout
- run: go mod download && go mod verify
- setup_remote_docker:
version: 20.10.6
- *enable_experimental_docker_features
- *install_vault
- rok8s/get_vault_env:
vault_path: repo/global/env
- rok8s/docker_login:
registry: "quay.io"
username: $FAIRWINDS_QUAY_USER
password-variable: FAIRWINDS_QUAY_TOKEN
- run: go get github.com/markbates/pkger/cmd/pkger
- run: pkger
- *install_goreleaser
- run: goreleaser
snapshot:
working_directory: /go/src/github.com/fairwindsops/pluto
resource_class: large
docker:
- image: goreleaser/goreleaser:v0.174.2
steps:
- checkout
- setup_remote_docker:
version: 20.10.6
- *enable_experimental_docker_features
- *install_vault
- rok8s/get_vault_env:
vault_path: repo/global/env
- rok8s/docker_login:
registry: "quay.io"
username: $FAIRWINDS_QUAY_USER
password-variable: FAIRWINDS_QUAY_TOKEN
- run: go get github.com/markbates/pkger/cmd/pkger
- run: pkger
- run: goreleaser --debug --snapshot
publish_docs:
docker:
- image: cimg/node:15.5.1
Expand Down Expand Up @@ -105,32 +143,29 @@ workflows:
test:
jobs:
- test
- rok8s-scripts/kubernetes_e2e_tests:
- snapshot:
requires:
- test
filters:
branches:
only: /.*/
tags:
ignore: /.*/
name: functional tests
<<: *e2e_config
- rok8s-scripts/docker_build_and_push:
name: build-and-push-container
docker-push: true
enable_docker_layer_caching: false
config_file: .circleci/build.config
context: org-global
docker-login: true
password-variable: "fairwinds_quay_token"
registry: quay.io
username: fairwinds+circleci
- rok8s/kubernetes_e2e_tests:
requires:
- test
- rok8s-scripts/insights:
filters:
branches:
only: /.*/
tags:
ignore: /.*/
name: functional tests
<<: *e2e_config
- rok8s/insights:
name: insights
requires:
- build-and-push-container
- test
- snapshot
release:
jobs:
- publish_docs:
Expand All @@ -139,22 +174,7 @@ workflows:
ignore: /.*/
tags:
only: /.*/
- release_binary:
filters:
branches:
ignore: /.*/
tags:
only: /.*/
- rok8s-scripts/docker_build_and_push:
name: build-and-push-container
docker-push: true
enable_docker_layer_caching: false
config_file: .circleci/build.config
context: org-global
docker-login: true
password-variable: "fairwinds_quay_token"
registry: quay.io
username: fairwinds+circleci
- release:
filters:
branches:
ignore: /.*/
Expand Down
46 changes: 45 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
brews:
- name: pluto
github:
goarm: 6
tap:
owner: FairwindsOps
name: homebrew-tap
folder: Formula
Expand All @@ -22,3 +23,46 @@ builds:
goarm:
- 6
- 7
dockers:
- image_templates:
- "quay.io/fairwinds/saffire:{{ .Tag }}-amd64"
- "quay.io/fairwinds/saffire:v{{ .Major }}-amd64"
- "quay.io/fairwinds/saffire:v{{ .Major }}.{{ .Minor }}-amd64"
use_buildx: true
dockerfile: Dockerfile
build_flag_templates:
- "--platform=linux/amd64"
- image_templates:
- "quay.io/fairwinds/saffire:{{ .Tag }}-arm64v8"
- "quay.io/fairwinds/saffire:v{{ .Major }}-arm64v8"
- "quay.io/fairwinds/saffire:v{{ .Major }}.{{ .Minor }}-arm64v8"
use_buildx: true
goarch: arm64
dockerfile: Dockerfile
build_flag_templates:
- "--platform=linux/arm64/v8"
- image_templates:
- "quay.io/fairwinds/saffire:{{ .Tag }}-armv7"
- "quay.io/fairwinds/saffire:v{{ .Major }}-armv7"
- "quay.io/fairwinds/saffire:v{{ .Major }}.{{ .Minor }}-armv7"
use_buildx: true
goarch: arm64
dockerfile: Dockerfile
build_flag_templates:
- "--platform=linux/arm/v7"
docker_manifests:
- name_template: quay.io/fairwinds/saffire:{{ .Tag }}
image_templates:
- "quay.io/fairwinds/saffire:{{ .Tag }}-amd64"
- "quay.io/fairwinds/saffire:{{ .Tag }}-arm64v8"
- "quay.io/fairwinds/saffire:{{ .Tag }}-armv7"
- name_template: quay.io/fairwinds/saffire:v{{ .Major }}
image_templates:
- "quay.io/fairwinds/saffire:v{{ .Major }}-amd64"
- "quay.io/fairwinds/saffire:v{{ .Major }}-arm64v8"
- "quay.io/fairwinds/saffire:v{{ .Major }}-armv7"
- name_template: quay.io/fairwinds/saffire:v{{ .Major }}.{{ .Minor }}
image_templates:
- "quay.io/fairwinds/saffire:v{{ .Major }}.{{ .Minor }}-amd64"
- "quay.io/fairwinds/saffire:v{{ .Major }}.{{ .Minor }}-arm64v8"
- "quay.io/fairwinds/saffire:v{{ .Major }}.{{ .Minor }}-armv7"
20 changes: 2 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
FROM golang:1.16 AS build-env
WORKDIR /go/src/github.com/fairwindsops/pluto/

ARG version=dev
ARG commit=none

COPY go.mod .
COPY go.sum .
RUN go mod download

COPY . .
RUN go get github.com/markbates/pkger/cmd/pkger
RUN VERSION=$version COMMIT=$commit make build-linux

FROM alpine:3.13
RUN apk --no-cache --update add ca-certificates tzdata && update-ca-certificates
FROM alpine:3.14

USER nobody
COPY --from=build-env /go/src/github.com/fairwindsops/pluto /
COPY pluto /

WORKDIR /opt/app
ENTRYPOINT ["/pluto"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ clean:
build-linux:
pkger
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME) -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -s -w" -v
build-docker:
build-docker: build-linux
docker build --build-arg version=$(VERSION) --build-arg commit=$(COMMIT) -t quay.io/reactiveops/$(BINARY_NAME):dev .

0 comments on commit fb98229

Please sign in to comment.