Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(agent): make docker image multiarch #3279

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,6 @@ jobs:
ANALYTICS_BE_KEY: ${{ secrets.ANALYTICS_BE_KEY }}
TRACETEST_DEFAULT_CLOUD_ENDPOINT: ${{ secrets.TRACETEST_DEFAULT_CLOUD_ENDPOINT }}

# release agent
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now handled by goreleaser on the main release step

- name: Build and push agent
uses: docker/build-push-action@v5
with:
push: true
tags: kubeshop/tracetest-agent:latest,kubeshop/tracetest-agent:${{ env.VERSION }}
file: agent/Dockerfile
build-args: |
TRACETEST_VERSION=${{ env.VERSION }}
env:
VERSION: ${{ github.ref_name }}



helm_chart_version_bump:
name: "Trigger Helm chart appVersion update"
needs: "release"
Expand Down
14 changes: 14 additions & 0 deletions .goreleaser.demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ dockers:
- "--platform=linux/amd64"
goos: linux
goarch: amd64

- image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-amd64'
dockerfile: "Dockerfile.agent"
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}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
goos: linux
goarch: amd64
15 changes: 15 additions & 0 deletions .goreleaser.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,18 @@ dockers:
- "--platform=linux/amd64"
goos: linux
goarch: amd64

- skip_push: true
image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}'
dockerfile: "Dockerfile.agent"
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}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
goos: linux
goarch: amd64
37 changes: 37 additions & 0 deletions .goreleaser.rc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,49 @@ dockers:
goarch: arm64
use: buildx

# agent
- image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-amd64'
dockerfile: "Dockerfile.agent"
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}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
goos: linux
goarch: amd64
use: buildx

- image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-arm64'
dockerfile: "Dockerfile.agent"
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}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/arm64/v8"
goos: linux
goarch: arm64
use: buildx

docker_manifests:
- name_template: 'kubeshop/tracetest:{{ .Env.VERSION }}'
image_templates:
- 'kubeshop/tracetest:{{ .Env.VERSION }}-amd64'
- 'kubeshop/tracetest:{{ .Env.VERSION }}-arm64'

# agent
- name_template: 'kubeshop/tracetest-agent:{{ .Env.VERSION }}'
image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-amd64'
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-arm64'

archives:
- name_template: >-
{{ .ProjectName }}_
Expand Down
41 changes: 41 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,37 @@ dockers:
goarch: arm64
use: buildx

# agent
- image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-amd64'
dockerfile: "Dockerfile.agent"
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}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
goos: linux
goarch: amd64
use: buildx

- image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-arm64'
dockerfile: "Dockerfile.agent"
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}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/arm64/v8"
goos: linux
goarch: arm64
use: buildx

docker_manifests:
- name_template: 'kubeshop/tracetest:{{ .Env.VERSION }}'
image_templates:
Expand All @@ -122,6 +153,16 @@ docker_manifests:
- 'kubeshop/tracetest:{{ .Env.VERSION }}-amd64'
- 'kubeshop/tracetest:{{ .Env.VERSION }}-arm64'

# agent
- name_template: 'kubeshop/tracetest-agent:{{ .Env.VERSION }}'
image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-amd64'
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-arm64'
- name_template: '{{ if not .IsNightly }}kubeshop/tracetest-agent:latest{{ end }}'
image_templates:
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-amd64'
- 'kubeshop/tracetest-agent:{{ .Env.VERSION }}-arm64'

archives:
- name_template: >-
{{ .ProjectName }}_
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile.agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine

ENV PATH="$PATH:/app"
ENV TRACETEST_API_KEY ""

WORKDIR /app

COPY ./tracetest /app/tracetest

ENTRYPOINT [ "tracetest", "start", "--api-key", "$TRACETEST_API_KEY" ]

9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION?="dev"
VERSION?=dev
TAG?=$(VERSION)
GORELEASER_VERSION=1.21.2-pro

Expand Down Expand Up @@ -31,9 +31,10 @@ WEB_SRC_FILES := $(shell find web -type f -not -path "*node_modules*" -not -path
web/build: web/node_modules $(WEB_SRC_FILES)
cd web; npm run build

dist/docker-image-$(TAG).tar: $(CLI_SRC_FILES) $(SERVER_SRC_FILES) $(WEB_SRC_FILES)
dist/tracetest-docker-$(TAG).tar dist/tracetest-agent-docker-$(TAG).tar: $(CLI_SRC_FILES) $(SERVER_SRC_FILES) $(WEB_SRC_FILES)
goreleaser release --clean --skip-announce --snapshot -f .goreleaser.dev.yaml
docker save --output dist/docker-image-$(TAG).tar "kubeshop/tracetest:$(TAG)"
docker save --output dist/tracetest-docker-$(TAG).tar "kubeshop/tracetest:$(TAG)"
docker save --output dist/tracetest-agent-docker-$(TAG).tar "kubeshop/tracetest-agent:$(TAG)"

help: Makefile ## show list of commands
@echo "Choose a command run:"
Expand All @@ -51,7 +52,7 @@ run: build-docker ## build and run tracetest using docker compose
docker compose up
build-go: dist/tracetest dist/tracetest-server ## build all go code
build-web: web/build ## build web
build-docker: goreleaser-version web/build .goreleaser.dev.yaml dist/docker-image-$(TAG).tar ## build and tag docker image as defined in .goreleaser.dev.yaml
build-docker: goreleaser-version web/build .goreleaser.dev.yaml dist/tracetest-docker-$(TAG).tar dist/tracetest-agent-docker-$(TAG).tar ## build and tag docker image as defined in .goreleaser.dev.yaml

.PHONY: generate generate-server generate-cli generate-web
generate: generate-server generate-cli generate-web ## generate code entities from openapi definitions for all parts of the code
Expand Down
3 changes: 2 additions & 1 deletion cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/davecgh/go-spew v1.1.1
github.com/denisbrodbeck/machineid v1.0.1
github.com/goccy/go-yaml v1.11.0
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/golang-jwt/jwt v3.2.1+incompatible
github.com/goware/urlx v0.3.2
github.com/kubeshop/tracetest/agent v0.0.0-20230907210810-84198fc9f4ef
github.com/kubeshop/tracetest/server v0.0.0-20231010015728-ab7381aa0030
Expand Down Expand Up @@ -63,6 +63,7 @@ require (
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
Expand Down
1 change: 1 addition & 0 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c=
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
Expand Down