Skip to content

Commit

Permalink
build: use goreleaser to build and publis images
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
  • Loading branch information
leogr authored and poiana committed Mar 31, 2020
1 parent c678a71 commit 3a052c1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 46 deletions.
23 changes: 23 additions & 0 deletions .goreleaser.yml
Expand Up @@ -14,6 +14,29 @@ builds:
- CGO_ENABLED=0
binary: falco-exporter

dockers:
-
goos: linux
goarch: amd64
skip_push: false
dockerfile: build/Dockerfile
image_templates:
- "falcosecurity/falco-exporter:latest"
- "falcosecurity/falco-exporter:{{ .Version }}"
- "falcosecurity/falco-exporter:{{ .Major }}.{{ .Minor }}"
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
extra_files:
- cmd
- pkg
- go.mod
- go.sum
- Makefile

snapshot:
name_template: 'master'

Expand Down
33 changes: 0 additions & 33 deletions Makefile
@@ -1,47 +1,14 @@
SHELL=/bin/bash -o pipefail

DOCKER ?= docker
GO ?= go
HELM ?= helm

COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT_NO}-dirty,${COMMIT_NO})
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")

IMAGE_NAME_BUILDER_BASE ?= docker.io/falcosecurity/falco-exporter

IMAGE_NAME_BUILDER_BASE_BRANCH := $(IMAGE_NAME_BUILDER_BASE):$(GIT_BRANCH_CLEAN)
IMAGE_NAME_BUILDER_BASE_COMMIT := $(IMAGE_NAME_BUILDER_BASE):$(GIT_COMMIT)
IMAGE_NAME_BUILDER_BASE_LATEST := $(IMAGE_NAME_BUILDER_BASE):latest

TEST_FLAGS ?= -v -race

export GO111MODULE=on

.PHONY: falco-exporter
falco-exporter:
$(GO) build ./cmd/falco-exporter

.PHONY: image/build
image/build:
$(DOCKER) build \
-t "$(IMAGE_NAME_BUILDER_BASE_BRANCH)" \
-f build/Dockerfile .
$(DOCKER) tag $(IMAGE_NAME_BUILDER_BASE_BRANCH) $(IMAGE_NAME_BUILDER_BASE_COMMIT)
$(DOCKER) tag "$(IMAGE_NAME_BUILDER_BASE_BRANCH)" $(IMAGE_NAME_BUILDER_BASE_COMMIT)


.PHONY: image/push
image/push:
$(DOCKER) push $(IMAGE_NAME_BUILDER_BASE_BRANCH)
$(DOCKER) push $(IMAGE_NAME_BUILDER_BASE_COMMIT)

.PHONY: image/latest
image/latest:
$(DOCKER) tag $(IMAGE_NAME_BUILDER_BASE_COMMIT) $(IMAGE_NAME_BUILDER_BASE_LATEST)
$(DOCKER) push $(IMAGE_NAME_BUILDER_BASE_LATEST)

.PHONY: deploy/k8s/templates
deploy/k8s/templates:
rm -rf deploy/k8s/templates/*
Expand Down
16 changes: 3 additions & 13 deletions release.md
@@ -1,8 +1,6 @@
# Release Process

Currently, our release process is partially automated. We use:
- the [goreleaser](https://github.com/goreleaser/goreleaser) tool for artifacts
- the provided `Makefile` for the container image
Currently, our release process is partially automated. We use the [goreleaser](https://github.com/goreleaser/goreleaser) tool for artifacts.

When we release we do the following process:

Expand All @@ -27,15 +25,7 @@ export GITHUB_TOKEN=<YOUR_GH_TOKEN>
goreleaser --rm-dist
```

Finally, build and publish the container image

```
make image/build
make image/push
make image/latest
```

## TODO

- [ ] Setup goreleaser [on a CI system](https://goreleaser.com/ci/), ie., CircleCI
- [ ] Build and publish images using a CI system, ie., CircleCI
- [x] Setup goreleaser to build and publish images
- [ ] Setup goreleaser [on a CI system](https://goreleaser.com/ci/), ie., CircleCI

0 comments on commit 3a052c1

Please sign in to comment.