diff --git a/.circleci/config.yml b/.circleci/config.yml index c3e8daeb..59301f4e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - rok8s-scripts: fairwinds/rok8s-scripts@11 + rok8s: fairwinds/rok8s-scripts@11 executors: golang-exec: @@ -9,14 +9,6 @@ executors: - 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" @@ -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 \< /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 @@ -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 @@ -105,7 +143,7 @@ workflows: test: jobs: - test - - rok8s-scripts/kubernetes_e2e_tests: + - snapshot: requires: - test filters: @@ -113,24 +151,21 @@ workflows: 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: @@ -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: /.*/ diff --git a/.goreleaser.yml b/.goreleaser.yml index 5a6128a1..7e13ece0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,6 +1,7 @@ brews: - name: pluto - github: + goarm: 6 + tap: owner: FairwindsOps name: homebrew-tap folder: Formula @@ -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" diff --git a/Dockerfile b/Dockerfile index ffa2aed9..373a5a55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/Makefile b/Makefile index 5ac8cd60..8149662e 100644 --- a/Makefile +++ b/Makefile @@ -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 .