Skip to content

Commit

Permalink
chore(agent): make docker image multiarch (#3279)
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren committed Oct 18, 2023
1 parent b69ddd1 commit 3d055da
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 18 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/release-version.yml
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
- 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
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
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
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
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
@@ -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
@@ -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

0 comments on commit 3d055da

Please sign in to comment.