Skip to content

Commit

Permalink
build binaries and image for arm64 and arm
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Panato <ctadeu@gmail.com>
  • Loading branch information
cpanato committed Dec 5, 2021
1 parent cefd9b8 commit f48f5a0
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 35 deletions.
38 changes: 34 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,41 @@ jobs:
docker push public.ecr.aws/falcosecurity/falcosidekick:latest
release:
executor:
name: default
machine:
image: ubuntu-2004:202111-01
environment:
DOCKER_BUILDKIT: 1
BUILDX_PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
steps:
- checkout
- setup_remote_docker
- run:
name: Update Go
command: |
GOLANG_URL="https://go.dev/dl/go1.16.11.linux-amd64.tar.gz"
curl --output go1.16.11.linux-amd64.tar.gz \
--silent --show-error --location --fail --retry 3 \
"$GOLANG_URL"
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.16.11.linux-amd64.tar.gz
go version
- run:
name: Install buildx
command: |
BUILDX_BINARY_URL="https://github.com/docker/buildx/releases/download/v0.7.0/buildx-v0.7.0.linux-amd64"
curl --output docker-buildx \
--silent --show-error --location --fail --retry 3 \
"$BUILDX_BINARY_URL"
mkdir -p ~/.docker/cli-plugins
mv docker-buildx ~/.docker/cli-plugins/
chmod a+x ~/.docker/cli-plugins/docker-buildx
docker buildx install
# Run binfmt
docker run --rm --privileged tonistiigi/binfmt:latest --install "$BUILDX_PLATFORMS"
- run:
name: Install pre-requisites
command: |
Expand All @@ -81,7 +111,7 @@ jobs:
./aws/install -i $HOME/.local/aws-cli -b $HOME/.local/bin
popd && rm -r $DIR
- run:
name: Prepare env
name: Login Registries
command: |
echo ${DOCKERHUB_SECRET} | docker login -u ${DOCKERHUB_USER} --password-stdin
aws ecr-public get-login-password --region us-east-1 | \
Expand Down
98 changes: 82 additions & 16 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,112 @@
project_name: falcosidekick

snapshot:
name_template: '{{ incpatch .Version }}-next'

checksum:
name_template: 'checksums.txt'

builds:
- id: "falcosidekick"
goos:
- linux
- linux
goarch:
- amd64
- amd64
- arm64
- arm
goarm:
- '7'
asmflags:
- all=-trimpath={{.Env.GOPATH}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
env:
- CGO_ENABLED=0
flags:
- -trimpath
binary: falcosidekick

dockers:
- goos: linux
goarch: amd64
dockerfile: Dockerfile
use: buildx
image_templates:
- "falcosecurity/falcosidekick:stable-amd64"
- "falcosecurity/falcosidekick:{{ .Version }}-amd64"
- "public.ecr.aws/falcosecurity/falcosidekick:stable-amd64"
- "public.ecr.aws/falcosecurity/falcosidekick:{{ .Version }}-amd64"
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}}"
- "--platform=linux/amd64"
extra_files:
- LICENSE

- goos: linux
goarch: arm64
dockerfile: Dockerfile
use: buildx
image_templates:
- "falcosecurity/falcosidekick:stable-arm64"
- "falcosecurity/falcosidekick:{{ .Version }}-arm64"
- "public.ecr.aws/falcosecurity/falcosidekick:stable-arm64"
- "public.ecr.aws/falcosecurity/falcosidekick:{{ .Version }}-arm64"
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}}"
- "--platform=linux/arm64"
extra_files:
- LICENSE

- goos: linux
goarch: arm
goarm: '7'
dockerfile: Dockerfile
use: buildx
image_templates:
- "falcosecurity/falcosidekick:stable"
- "falcosecurity/falcosidekick:{{ .Version }}"
- "public.ecr.aws/falcosecurity/falcosidekick:stable"
- "public.ecr.aws/falcosecurity/falcosidekick:{{ .Version }}"
- "falcosecurity/falcosidekick:stable-armv7"
- "falcosecurity/falcosidekick:{{ .Version }}-armv7"
- "public.ecr.aws/falcosecurity/falcosidekick:stable-armv7"
- "public.ecr.aws/falcosecurity/falcosidekick:{{ .Version }}-armv7"
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}}"
- "--platform=linux/arm/v7"
extra_files:
- outputs
- types
- config.go
- handlers.go
- main.go
- stats_prometheus.go
- stats.go
- go.mod
- go.sum
- Makefile
- LICENSE

docker_manifests:
- name_template: 'falcosecurity/falcosidekick:stable'
image_templates:
- 'falcosecurity/falcosidekick:stable-amd64'
- 'falcosecurity/falcosidekick:stable-arm64'
- 'falcosecurity/falcosidekick:stable-armv7'
- name_template: 'falcosecurity/falcosidekick:{{ .Version }}'
image_templates:
- 'falcosecurity/falcosidekick:{{ .Version }}-amd64'
- 'falcosecurity/falcosidekick:{{ .Version }}-arm64'
- 'falcosecurity/falcosidekick:{{ .Version }}-armv7'
- name_template: 'public.ecr.aws/falcosecurity/falcosidekick:stable'
image_templates:
- 'public.ecr.aws/falcosecurity/falcosidekick:stable-amd64'
- 'public.ecr.aws/falcosecurity/falcosidekick:stable-arm64'
- 'public.ecr.aws/falcosecurity/falcosidekick:stable-armv7'
- name_template: 'public.ecr.aws/falcosecurity/falcosidekick:{{ .Version }}'
image_templates:
- 'public.ecr.aws/falcosecurity/falcosidekick:{{ .Version }}-amd64'
- 'public.ecr.aws/falcosecurity/falcosidekick:{{ .Version }}-arm64'
- 'public.ecr.aws/falcosecurity/falcosidekick:{{ .Version }}-armv7'

release:
github:
prerelease: auto
16 changes: 2 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
ARG BUILDER_IMAGE=golang:1.16-buster
ARG BASE_IMAGE=alpine:3.12

FROM ${BUILDER_IMAGE} AS build-stage

ENV CGO_ENABLED=0

WORKDIR /src
COPY . .

RUN go mod download
RUN make falcosidekick

# Final Docker image
FROM ${BASE_IMAGE} AS final-stage
LABEL MAINTAINER "Thomas Labarussias <issif+falcosidekick@gadz.org>"
Expand All @@ -24,8 +12,8 @@ RUN addgroup -S falcosidekick && adduser -u 1234 -S falcosidekick -G falcosideki
USER 1234

WORKDIR ${HOME}/app
COPY --from=build-stage /src/LICENSE .
COPY --from=build-stage /src/falcosidekick .
COPY LICENSE .
COPY falcosidekick .

EXPOSE 2801

Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
falcosidekick:
$(GO) build -gcflags all=-trimpath=/src -asmflags all=-trimpath=/src -a -installsuffix cgo -o $@ .

.PHONY: falcosidekick-linux-amd64
falcosidekick-linux-amd64:
GOOS=linux GOARCH=amd64 $(GO) build -gcflags all=-trimpath=/src -asmflags all=-trimpath=/src -a -installsuffix cgo -o $@ .

.PHONY: build-image
build-image:
build-image: falcosidekick-linux-amd64
$(DOCKER) build . -t falcosecurity/falcosidekick:latest

## --------------------------------------
Expand Down

0 comments on commit f48f5a0

Please sign in to comment.