Skip to content

Commit

Permalink
Add arm32v7 to release configurations (#349)
Browse files Browse the repository at this point in the history
* Add arm32v7 to release configurations

* Update config generator to allow for arm version

* Update list of goarch builds with arm

* Fix docker tag
  • Loading branch information
Wal8800 authored Jul 20, 2023
1 parent 88c6821 commit 0450858
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 16 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci-goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ jobs:
strategy:
matrix:
GOOS: [linux, windows, darwin]
GOARCH: ["386", amd64, arm64, ppc64le]
GOARCH: ["386", amd64, arm64, ppc64le, arm]
exclude:
- GOOS: darwin
GOARCH: "386"
- GOOS: windows
GOARCH: arm64
- GOOS: darwin
GOARCH: arm
- GOOS: windows
GOARCH: arm
runs-on: ubuntu-20.04

steps:
Expand All @@ -37,7 +41,7 @@ jobs:
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64,ppc64le
platforms: arm64,ppc64le,linux/arm/v7

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ jobs:
strategy:
matrix:
GOOS: [linux, windows, darwin]
GOARCH: ["386", amd64, arm64, ppc64le]
GOARCH: ["386", amd64, arm64, ppc64le, arm]
exclude:
- GOOS: darwin
GOARCH: "386"
- GOOS: windows
GOARCH: arm64
- GOOS: darwin
GOARCH: arm
- GOOS: windows
GOARCH: arm
runs-on: ubuntu-20.04

steps:
Expand All @@ -26,7 +30,7 @@ jobs:

- uses: docker/setup-qemu-action@v2
with:
platforms: arm64,ppc64le
platforms: arm64,ppc64le,linux/arm/v7

- uses: docker/setup-buildx-action@v2

Expand Down
62 changes: 62 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ builds:
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64le
goarm:
- "7"
ignore:
- goos: darwin
goarch: "386"
- goos: darwin
goarch: arm
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
dir: distributions/otelcol/_build
Expand All @@ -34,11 +41,18 @@ builds:
goarch:
- "386"
- amd64
- arm
- arm64
- ppc64le
goarm:
- "7"
ignore:
- goos: darwin
goarch: "386"
- goos: darwin
goarch: arm
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
dir: distributions/otelcol-contrib/_build
Expand Down Expand Up @@ -149,6 +163,26 @@ dockers:
- --label=org.opencontainers.image.version={{.Version}}
- --label=org.opencontainers.image.source={{.GitURL}}
use: buildx
- goos: linux
goarch: arm
goarm: "7"
dockerfile: distributions/otelcol/Dockerfile
image_templates:
- otel/opentelemetry-collector:{{ .Version }}-armv7
- otel/opentelemetry-collector:latest-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest-armv7
extra_files:
- configs/otelcol.yaml
build_flag_templates:
- --pull
- --platform=linux/arm/v7
- --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}}
use: buildx
- goos: linux
goarch: arm64
dockerfile: distributions/otelcol/Dockerfile
Expand Down Expand Up @@ -225,6 +259,26 @@ dockers:
- --label=org.opencontainers.image.version={{.Version}}
- --label=org.opencontainers.image.source={{.GitURL}}
use: buildx
- goos: linux
goarch: arm
goarm: "7"
dockerfile: distributions/otelcol-contrib/Dockerfile
image_templates:
- otel/opentelemetry-collector-contrib:{{ .Version }}-armv7
- otel/opentelemetry-collector-contrib:latest-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest-armv7
extra_files:
- configs/otelcol-contrib.yaml
build_flag_templates:
- --pull
- --platform=linux/arm/v7
- --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}}
use: buildx
- goos: linux
goarch: arm64
dockerfile: distributions/otelcol-contrib/Dockerfile
Expand Down Expand Up @@ -268,47 +322,55 @@ docker_manifests:
image_templates:
- otel/opentelemetry-collector:{{ .Version }}-386
- otel/opentelemetry-collector:{{ .Version }}-amd64
- otel/opentelemetry-collector:{{ .Version }}-armv7
- otel/opentelemetry-collector:{{ .Version }}-arm64
- otel/opentelemetry-collector:{{ .Version }}-ppc64le
- name_template: otel/opentelemetry-collector:latest
image_templates:
- otel/opentelemetry-collector:latest-386
- otel/opentelemetry-collector:latest-amd64
- otel/opentelemetry-collector:latest-armv7
- otel/opentelemetry-collector:latest-arm64
- otel/opentelemetry-collector:latest-ppc64le
- name_template: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}
image_templates:
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}-386
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}-arm64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:{{ .Version }}-ppc64le
- name_template: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest
image_templates:
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest-386
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest-arm64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:latest-ppc64le
- name_template: otel/opentelemetry-collector-contrib:{{ .Version }}
image_templates:
- otel/opentelemetry-collector-contrib:{{ .Version }}-386
- otel/opentelemetry-collector-contrib:{{ .Version }}-amd64
- otel/opentelemetry-collector-contrib:{{ .Version }}-armv7
- otel/opentelemetry-collector-contrib:{{ .Version }}-arm64
- otel/opentelemetry-collector-contrib:{{ .Version }}-ppc64le
- name_template: otel/opentelemetry-collector-contrib:latest
image_templates:
- otel/opentelemetry-collector-contrib:latest-386
- otel/opentelemetry-collector-contrib:latest-amd64
- otel/opentelemetry-collector-contrib:latest-armv7
- otel/opentelemetry-collector-contrib:latest-arm64
- otel/opentelemetry-collector-contrib:latest-ppc64le
- name_template: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}
image_templates:
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}-386
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}-arm64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:{{ .Version }}-ppc64le
- name_template: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest
image_templates:
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest-386
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest-amd64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest-armv7
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest-arm64
- ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest-ppc64le
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ make goreleaser-verify

#### Building multi-architecture Docker images

goreleaser will build Docker images for x86_64 and arm64 processors. The build process involves executing `RUN` steps on the target architecture, which means the system you run it on needs support for emulating foreign architectures.
goreleaser will build Docker images for x86_64, 386, arm, arm64 and ppc64le processors. The build process involves executing `RUN` steps on the target architecture, which means the system you run it on needs support for emulating foreign architectures.

This is accomplished by installing [qemu](https://www.qemu.org/), and then [enabling support](https://github.com/multiarch/qemu-user-static#readme) for qemu within Docker:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This repository assembles OpenTelemetry Collector distributions, such as the "co
Each distribution contains:

- Binaries for a multitude of platforms and architectures
- Multi-arch container images (x86_64 and arm64)
- Multi-arch container images (x86_64, 386, arm, arm64 and ppc64le)
- Packages to be used with Linux distributions (apk, RPM, deb), Mac OS (brew)

More details about each individual distribution can be seen in its own readme files.
Expand Down
57 changes: 47 additions & 10 deletions cmd/goreleaser/internal/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ import (
"github.com/goreleaser/nfpm/v2/files"
)

const ArmArch = "arm"

var (
ImagePrefixes = []string{"otel", "ghcr.io/open-telemetry/opentelemetry-collector-releases"}
Architectures = []string{"386", "amd64", "arm64", "ppc64le"}
Architectures = []string{"386", "amd64", "arm", "arm64", "ppc64le"}
ArmVersions = []string{"7"}
)

func Generate(imagePrefixes []string, dists []string) config.Project {
Expand Down Expand Up @@ -69,8 +72,11 @@ func Build(dist string) config.Build {
},
Goos: []string{"darwin", "linux", "windows"},
Goarch: Architectures,
Goarm: ArmVersions,
Ignore: []config.IgnoredBuild{
{Goos: "darwin", Goarch: "386"},
{Goos: "darwin", Goarch: "arm"},
{Goos: "windows", Goarch: "arm"},
{Goos: "windows", Goarch: "arm64"},
},
}
Expand Down Expand Up @@ -142,21 +148,30 @@ func Package(dist string) config.NFPM {
func DockerImages(imagePrefixes, dists []string) (r []config.Docker) {
for _, dist := range dists {
for _, arch := range Architectures {
r = append(r, DockerImage(imagePrefixes, dist, arch))
switch arch {
case ArmArch:
for _, vers := range ArmVersions {
r = append(r, DockerImage(imagePrefixes, dist, arch, vers))
}
default:
r = append(r, DockerImage(imagePrefixes, dist, arch, ""))
}
}
}
return
}

// DockerImage configures goreleaser to build a container image.
// https://goreleaser.com/customization/docker/
func DockerImage(imagePrefixes []string, dist, arch string) config.Docker {
func DockerImage(imagePrefixes []string, dist, arch, armVersion string) config.Docker {
dockerArchName := archName(arch, armVersion)
var imageTemplates []string
for _, prefix := range imagePrefixes {
dockerArchTag := strings.ReplaceAll(dockerArchName, "/", "")
imageTemplates = append(
imageTemplates,
fmt.Sprintf("%s/%s:{{ .Version }}-%s", prefix, imageName(dist), arch),
fmt.Sprintf("%s/%s:latest-%s", prefix, imageName(dist), arch),
fmt.Sprintf("%s/%s:{{ .Version }}-%s", prefix, imageName(dist), dockerArchTag),
fmt.Sprintf("%s/%s:latest-%s", prefix, imageName(dist), dockerArchTag),
)
}

Expand All @@ -171,7 +186,7 @@ func DockerImage(imagePrefixes []string, dist, arch string) config.Docker {
Use: "buildx",
BuildFlagTemplates: []string{
"--pull",
fmt.Sprintf("--platform=linux/%s", arch),
fmt.Sprintf("--platform=linux/%s", dockerArchName),
label("created", ".Date"),
label("name", ".ProjectName"),
label("revision", ".FullCommit"),
Expand All @@ -181,6 +196,7 @@ func DockerImage(imagePrefixes []string, dist, arch string) config.Docker {
Files: []string{path.Join("configs", fmt.Sprintf("%s.yaml", dist))},
Goos: "linux",
Goarch: arch,
Goarm: armVersion,
}
}

Expand All @@ -199,10 +215,21 @@ func DockerManifests(imagePrefixes, dists []string) (r []config.DockerManifest)
func DockerManifest(prefix, version, dist string) config.DockerManifest {
var imageTemplates []string
for _, arch := range Architectures {
imageTemplates = append(
imageTemplates,
fmt.Sprintf("%s/%s:%s-%s", prefix, imageName(dist), version, arch),
)
switch arch {
case ArmArch:
for _, armVers := range ArmVersions {
dockerArchTag := strings.ReplaceAll(archName(arch, armVers), "/", "")
imageTemplates = append(
imageTemplates,
fmt.Sprintf("%s/%s:%s-%s", prefix, imageName(dist), version, dockerArchTag),
)
}
default:
imageTemplates = append(
imageTemplates,
fmt.Sprintf("%s/%s:%s-%s", prefix, imageName(dist), version, arch),
)
}
}

return config.DockerManifest{
Expand All @@ -215,3 +242,13 @@ func DockerManifest(prefix, version, dist string) config.DockerManifest {
func imageName(dist string) string {
return strings.Replace(dist, "otelcol", "opentelemetry-collector", 1)
}

// archName translates architecture to docker platform names.
func archName(arch, armVersion string) string {
switch arch {
case ArmArch:
return fmt.Sprintf("%s/v%s", arch, armVersion)
default:
return arch
}
}

0 comments on commit 0450858

Please sign in to comment.