Repository: elastic/golang-crossbuild
Branch: main
Commit: 7f95b8418545
Files: 132
Total size: 166.4 KB
Directory structure:
gitextract_x3ml7gzw/
├── .buildkite/
│ ├── fpm-pipeline.yml
│ ├── hooks/
│ │ ├── pre-command
│ │ └── pre-exit
│ ├── llvm-apple-pipeline.yml
│ ├── pipeline.yml
│ ├── pull-requests.json
│ └── scripts/
│ ├── build.sh
│ ├── buildx.sh
│ ├── common.sh
│ ├── llvm-apple/
│ │ ├── build.sh
│ │ └── publish.sh
│ ├── llvm-fpm/
│ │ └── build_and_publish.sh
│ ├── post-release.sh
│ ├── publish.sh
│ └── validate-go-version.sh
├── .editorconfig
├── .github/
│ ├── CODEOWNERS
│ ├── actions/
│ │ └── bump-golang/
│ │ └── action.yml
│ ├── dependabot.yml
│ ├── release-drafter.yml
│ ├── updatecli.d/
│ │ ├── bump-go-version.sh
│ │ └── bump-golang.yml
│ └── workflows/
│ ├── bump-golang-previous.yml
│ ├── bump-golang.yml
│ ├── catalog-info.yml
│ └── release-drafter.yml
├── .gitignore
├── .go-version
├── .mergify.yml
├── .updatecli-version
├── LICENSE
├── Makefile
├── Makefile.common
├── NPCAP.md
├── README.md
├── RELEASE.md
├── catalog-info.yaml
├── fpm/
│ ├── .dockerignore
│ ├── Dockerfile.tmpl
│ ├── Makefile
│ └── rootfs/
│ └── entrypoint.sh
├── go/
│ ├── Makefile
│ ├── Makefile.common
│ ├── Makefile.debian10
│ ├── Makefile.debian11
│ ├── Makefile.debian12
│ ├── Makefile.debian7
│ ├── Makefile.debian8
│ ├── Makefile.debian9
│ ├── arm/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── armel/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── armhf/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── base/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ ├── rootfs/
│ │ │ └── entrypoint.go
│ │ ├── sources-debian10.list
│ │ ├── sources-debian11.list
│ │ ├── sources-debian12.list
│ │ ├── sources-debian7.list
│ │ ├── sources-debian8.list
│ │ └── sources-debian9.list
│ ├── base-arm/
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ ├── rootfs/
│ │ │ └── entrypoint.go
│ │ ├── sources-debian10.list
│ │ ├── sources-debian11.list
│ │ ├── sources-debian12.list
│ │ ├── sources-debian8.list
│ │ └── sources-debian9.list
│ ├── darwin/
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── darwin-arm64/
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── llvm-apple/
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ ├── lcxx.patch
│ │ ├── sources-debian10.list
│ │ ├── sources-debian11.list
│ │ └── sources-debian12.list
│ ├── main/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── mips/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── mips32/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── npcap/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── lib/
│ │ └── .gitkeep
│ ├── ppc/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ ├── s390x/
│ │ ├── .dockerignore
│ │ ├── Dockerfile.tmpl
│ │ ├── Makefile
│ │ └── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ └── windows-arm64/
│ ├── Dockerfile.tmpl
│ ├── Makefile
│ ├── rootfs/
│ │ ├── compilers.yaml
│ │ └── helloWorld.c
│ └── scripts/
│ ├── install-llvm-mingw64.sh
│ └── setup-llvm-mingw64.sh
└── template.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .buildkite/fpm-pipeline.yml
================================================
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
env:
IMAGE_UBUNTU_X86_64: "family/platform-ingest-eng-prod-base-ubuntu-2204"
STAGING_IMAGE: "docker.elastic.co/observability-ci"
MAKEFILE: "fpm"
BUILDX: "0"
# This section is used to define the plugins that will be used in the pipeline.
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
common:
- oblt_google_auth_plugin: &gcp_oidc_plugin
# See https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/golang-crossbuild/01-gcp-buildkite-oidc.tf
# This plugin authenticates to Google Cloud using the OIDC token.
elastic/oblt-google-auth#v1.3.0:
lifetime: 10800 # seconds
project-id: "elastic-observability-ci"
project-number: "911195782929"
- docker_elastic_login_plugin: &docker_elastic_login_plugin
elastic/vault-docker-login#v0.6.0:
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
- dockerhub_login_plugin: &dockerhub_login_plugin
elastic/vault-docker-login#v0.6.0:
secret_path: 'kv/ci-shared/observability-github-secrets/shared/docker/dockerhub/observabilityrobots'
steps:
- label: ":linux: multiarch Linux x86_64/arm64 FPM docker image"
key: "build-and-publish-ubuntu-x86-fpm"
if: build.env("BUILDKITE_PULL_REQUEST") != "false" || build.source == "ui" || build.branch == "main" || build.branch =~ /^[0-9]+\.[0-9]+$$/
command:
- ".buildkite/scripts/llvm-fpm/build_and_publish.sh ${MAKEFILE}"
notify:
- github_commit_status:
context: "Build FPM / Ubuntu X86_64"
env:
REPOSITORY: "${STAGING_IMAGE}"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
plugins:
- *gcp_oidc_plugin
- *docker_elastic_login_plugin
- *dockerhub_login_plugin
================================================
FILE: .buildkite/hooks/pre-command
================================================
#!/bin/bash
set -euo pipefail
source .buildkite/scripts/common.sh
if [[ "$BUILDKITE_PIPELINE_SLUG" == "golang-crossbuild" && "$BUILDKITE_STEP_KEY" == "release-post" ]]; then
export GITHUB_USERNAME="elasticmachine"
export GITHUB_EMAIL="elasticmachine@elastic.co"
export GITHUB_TOKEN_SECRET=$VAULT_GITHUB_TOKEN
fi
================================================
FILE: .buildkite/hooks/pre-exit
================================================
#!/bin/bash
set -euo pipefail
source .buildkite/scripts/common.sh
unset_secrets
# Ensure that any temporal files created during any step are removed
cleanup
================================================
FILE: .buildkite/llvm-apple-pipeline.yml
================================================
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
env:
IMAGE_UBUNTU_X86_64: "family/platform-ingest-eng-prod-base-ubuntu-2204"
IMAGE_UBUNTU_ARM_64: "platform-ingest-eng-prod-base-ubuntu-2204-aarch64"
INSTANCE_TYPE_ARM_64: "t4g.large"
STAGING_IMAGE: "docker.elastic.co/observability-ci"
MAKEFILE: "go/llvm-apple"
BUILDX: "0"
# This section is used to define the plugins that will be used in the pipeline.
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
common:
- oblt_google_auth_plugin: &gcp_oidc_plugin
# See https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/golang-crossbuild/01-gcp-buildkite-oidc.tf
# This plugin authenticates to Google Cloud using the OIDC token.
elastic/oblt-google-auth#v1.3.0:
lifetime: 20000 # seconds
project-id: "elastic-observability-ci"
project-number: "911195782929"
- docker_elastic_login_plugin: &docker_elastic_login_plugin
elastic/vault-docker-login#v0.6.0:
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
- dockerhub_login_plugin: &dockerhub_login_plugin
elastic/vault-docker-login#v0.6.0:
secret_path: 'kv/ci-shared/observability-github-secrets/shared/docker/dockerhub/observabilityrobots'
steps:
- label: ":linux: Build LLVM Apple / Ubuntu X86_64 - {{matrix.debianVersion}}"
key: "build-ubuntu-x86-llvm-apple"
if: build.env("BUILDKITE_PULL_REQUEST") != "false" || build.source == "ui" || build.branch == "main" || build.branch =~ /^[0-9]+\.[0-9]+$$/
command:
- ".buildkite/scripts/llvm-apple/build.sh ${MAKEFILE}"
- ".buildkite/scripts/llvm-apple/publish.sh ${MAKEFILE}"
notify:
- github_commit_status:
context: "Build LLVM Apple / Ubuntu X86_64"
env:
TAG_EXTENSION: "-debian{{matrix.debianVersion}}-amd64"
DEBIAN_VERSION: "{{matrix.debianVersion}}"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
plugins:
- *gcp_oidc_plugin
- *docker_elastic_login_plugin
- *dockerhub_login_plugin
matrix:
setup:
debianVersion:
- "10"
- "11"
- "12"
- label: ":linux: Build LLVM Apple / Ubuntu ARM - {{matrix.debianVersion}}"
key: "build-ubuntu-arm-llvm-apple"
if: build.env("BUILDKITE_PULL_REQUEST") != "false" || build.source == "ui" || build.branch == "main" || build.branch =~ /^[0-9]+\.[0-9]+$$/
command:
- ".buildkite/scripts/llvm-apple/build.sh ${MAKEFILE}"
- ".buildkite/scripts/llvm-apple/publish.sh ${MAKEFILE}"
notify:
- github_commit_status:
context: "Build LLVM Apple / Ubuntu ARM"
env:
TAG_EXTENSION: "-debian{{matrix.debianVersion}}-arm64"
DEBIAN_VERSION: "{{matrix.debianVersion}}"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "${INSTANCE_TYPE_ARM_64}"
plugins:
- *gcp_oidc_plugin
- *docker_elastic_login_plugin
- *dockerhub_login_plugin
matrix:
setup:
debianVersion:
- "10"
- "11"
- "12"
================================================
FILE: .buildkite/pipeline.yml
================================================
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
env:
SETUP_GVM_VERSION: "v0.6.0"
IMAGE_UBUNTU_X86_64: "family/platform-ingest-eng-prod-base-ubuntu-2204"
INSTANCE_TYPE_X86_64: "n2-standard-4"
IMAGE_UBUNTU_ARM_64: "platform-ingest-eng-prod-base-ubuntu-2204-aarch64"
INSTANCE_TYPE_ARM_64: "t4g.large"
STAGING_IMAGE: "docker.elastic.co/observability-ci"
BUILDX: 1
# This section is used to define the plugins that will be used in the pipeline.
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
common:
- oblt_google_auth_plugin: &gcp_oidc_plugin
# See https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/golang-crossbuild/01-gcp-buildkite-oidc.tf
# This plugin authenticates to Google Cloud using the OIDC token.
elastic/oblt-google-auth#v1.3.0:
lifetime: 10800 # seconds
project-id: "elastic-observability-ci"
project-number: "911195782929"
- docker_elastic_login_plugin: &docker_elastic_login_plugin
elastic/vault-docker-login#v0.6.0:
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
- dockerhub_login_plugin: &dockerhub_login_plugin
elastic/vault-docker-login#v0.6.0:
secret_path: 'kv/ci-shared/observability-github-secrets/shared/docker/dockerhub/observabilityrobots'
steps:
- label: ":linux: Validate Go version consistency"
command:
- ".buildkite/scripts/validate-go-version.sh"
- wait: ~
- group: "FPM"
key: "fpm"
steps:
- label: "Trigger fpm-pipeline"
if: build.pull_request.id != null && build.env("BUILDKITE_PULL_REQUEST_BASE_BRANCH") == "main"
if_changed:
- .buildkite/pipeline.yml
- .buildkite/fpm-pipeline.yml
- .buildkite/scripts/llvm-fpm
- fpm/**
command: "buildkite-agent pipeline upload .buildkite/fpm-pipeline.yml"
env:
BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}
BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
GITHUB_PR_LABELS: ${GITHUB_PR_LABELS}
# Trigger for the main branch only
- label: ":pipeline: Upload FPM Pipeline"
if: build.branch == 'main'
command: "buildkite-agent pipeline upload .buildkite/fpm-pipeline.yml"
env:
BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}
BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
GITHUB_PR_LABELS: ${GITHUB_PR_LABELS}
- group: "llvm-apple"
key: "llvm-apple"
steps:
- label: "Trigger llvm-apple-pipeline"
if: build.pull_request.id != null && build.env("BUILDKITE_PULL_REQUEST_BASE_BRANCH") == "main"
if_changed:
# As long as https://github.com/elastic/golang-crossbuild/issues/615
#- .buildkite/pipeline.yml
- .buildkite/llvm-apple-pipeline.yml
- .buildkite/scripts/llvm-apple
- go/llvm-apple/**
command: "buildkite-agent pipeline upload .buildkite/llvm-apple-pipeline.yml"
env:
BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}
BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
GITHUB_PR_LABELS: ${GITHUB_PR_LABELS}
# Trigger for the main branch only if no a scheduled build
- label: ":pipeline: Upload llvm-apple Pipeline"
if: build.branch == 'main' && build.source != "schedule"
command: "buildkite-agent pipeline upload .buildkite/llvm-apple-pipeline.yml"
env:
BUILDKITE_PULL_REQUEST: ${BUILDKITE_PULL_REQUEST}
BUILDKITE_PULL_REQUEST_BASE_BRANCH: ${BUILDKITE_PULL_REQUEST_BASE_BRANCH}
GITHUB_PR_LABELS: ${GITHUB_PR_LABELS}
- group: "Staging"
key: "staging"
steps:
- label: ":linux: Staging / Ubuntu X86_64 - {{matrix.makefile}} - fips: {{matrix.fips}}"
key: "build-ubuntu-x86"
command:
- ".buildkite/scripts/build.sh {{matrix.makefile}}"
- ".buildkite/scripts/publish.sh {{matrix.makefile}}"
env:
REPOSITORY: "${STAGING_IMAGE}"
FIPS: "{{matrix.fips}}"
if: build.env("BUILDKITE_PULL_REQUEST") != "false"
notify:
- github_commit_status:
context: "Staging / Ubuntu X86_64"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
instanceType: "${INSTANCE_TYPE_X86_64}"
plugins:
- *gcp_oidc_plugin
- *docker_elastic_login_plugin
- *dockerhub_login_plugin
retry:
automatic:
limit: 1
matrix:
setup:
makefile:
- "Makefile"
- "Makefile.debian7"
- "Makefile.debian8"
- "Makefile.debian9"
- "Makefile.debian10"
- "Makefile.debian11"
- "Makefile.debian12"
fips:
- "false"
- "true"
- label: ":linux: Staging / Ubuntu ARM - {{matrix.makefile}} - fips: {{matrix.fips}}"
key: "build-ubuntu-arm"
command:
- ".buildkite/scripts/build.sh {{matrix.makefile}}"
- ".buildkite/scripts/publish.sh {{matrix.makefile}}"
env:
REPOSITORY: "${STAGING_IMAGE}"
FIPS: "{{matrix.fips}}"
if: build.env("BUILDKITE_PULL_REQUEST") != "false"
notify:
- github_commit_status:
context: "Staging / Ubuntu ARM"
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "${INSTANCE_TYPE_ARM_64}"
plugins:
- *gcp_oidc_plugin
- *docker_elastic_login_plugin
- *dockerhub_login_plugin
retry:
automatic:
limit: 1
matrix:
setup:
makefile:
- "Makefile.debian8"
- "Makefile.debian9"
- "Makefile.debian10"
- "Makefile.debian11"
- "Makefile.debian12"
fips:
- "false"
- "true"
- group: "Release"
key: "release"
steps:
- label: ":linux: Release / Ubuntu X86_64 - {{matrix.makefile}} - fips: {{matrix.fips}}"
key: "release-ubuntu-x86"
command:
- ".buildkite/scripts/build.sh {{matrix.makefile}}"
- ".buildkite/scripts/publish.sh {{matrix.makefile}}"
env:
FIPS: "{{matrix.fips}}"
# Releases should only be for main for ^[0-9].[0-9] branches (therefore support for major.minor.patch.x too).
if: build.branch == "main" || build.branch =~ /^[0-9]+\.[0-9]+/ || build.branch =~ /^[0-9]+\.[0-9]+\.[0-9]+\.x$$/
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
instanceType: "${INSTANCE_TYPE_X86_64}"
plugins:
- *gcp_oidc_plugin
- *docker_elastic_login_plugin
- *dockerhub_login_plugin
retry:
automatic:
limit: 1
matrix:
setup:
makefile:
- "Makefile"
- "Makefile.debian7"
- "Makefile.debian8"
- "Makefile.debian9"
- "Makefile.debian10"
- "Makefile.debian11"
- "Makefile.debian12"
fips:
- "false"
- "true"
notify:
- github_commit_status:
context: "Release / Ubuntu X86_64"
- label: ":linux: Release / Ubuntu ARM - {{matrix.makefile}} - fips: {{matrix.fips}}"
key: "release-ubuntu-arm"
command:
- ".buildkite/scripts/build.sh {{matrix.makefile}}"
- ".buildkite/scripts/publish.sh {{matrix.makefile}}"
env:
FIPS: "{{matrix.fips}}"
# Releases should only be for main for ^[0-9].[0-9] branches (therefore support for major.minor.patch.x too).
if: build.branch == "main" || build.branch =~ /^[0-9]+\.[0-9]+$$/ || build.branch =~ /^[0-9]+\.[0-9]+\.[0-9]+\.x$$/
agents:
provider: "aws"
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
instanceType: "${INSTANCE_TYPE_ARM_64}"
plugins:
- *gcp_oidc_plugin
- *docker_elastic_login_plugin
- *dockerhub_login_plugin
retry:
automatic:
limit: 1
matrix:
setup:
makefile:
- "Makefile.debian8"
- "Makefile.debian9"
- "Makefile.debian10"
- "Makefile.debian11"
- "Makefile.debian12"
fips:
- "false"
- "true"
notify:
- github_commit_status:
context: "Release / Ubuntu ARM"
- label: "Post-Release"
key: "release-post"
command: ".buildkite/scripts/post-release.sh ${GOLANG_VERSION}"
# Releases should only be for main for ^[0-9].[0-9]$ branches.
if: build.branch == "main" || build.branch =~ /^[0-9]+\.[0-9]+$$/
depends_on:
- "release-ubuntu-x86"
- "release-ubuntu-arm"
notify:
- github_commit_status:
context: "Post-release"
agents:
provider: "gcp"
image: "${IMAGE_UBUNTU_X86_64}"
instanceType: "${INSTANCE_TYPE_X86_64}"
# TODO: look for the right slack channel. Robots team don't own this project.
notify:
- slack: "#observablt-bots"
if: build.state == "failed"
================================================
FILE: .buildkite/pull-requests.json
================================================
{
"jobs": [
{
"enabled": true,
"pipelineSlug": "golang-crossbuild",
"allow_org_users": true,
"allowed_repo_permissions": ["admin", "write"],
"allowed_list": ["dependabot[bot]", "mergify[bot]", "github-actions[bot]", "elastic-vault-github-plugin-prod[bot]"],
"set_commit_status": true,
"build_on_commit": true,
"build_on_comment": true,
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^/test$",
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^/test$",
"skip_ci_labels": [ ],
"skip_target_branches": [ ],
"skip_ci_on_only_changed": [ "\\.md$", ".mergify.yml", "^.github/" ],
"always_require_ci_on_changed": [ ],
"fail_on_not_mergeable": true
}
]
}
================================================
FILE: .buildkite/scripts/build.sh
================================================
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common.sh
MAKEFILE=${1}
check_is_arm
add_bin_path
with_go "${GOLANG_VERSION}"
with_mage
make -C go -f "${MAKEFILE}" build"${is_arm}" GS_BUCKET_PATH=golang-crossbuild-ci-internal
echo "--- List Docker images staging"
docker images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" --filter=reference="${STAGING_IMAGE}/golang-crossbuild"
echo "--- List Docker images production"
docker images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}" --filter=reference="docker.elastic.co/beats-dev/golang-crossbuild"
================================================
FILE: .buildkite/scripts/buildx.sh
================================================
#!/usr/bin/env bash
set -e
set +x
BUILDPLATFORM=${BUILDPLATFORM:-"linux/amd64,linux/arm64"}
BUILDER_NAME="multibuilder${RANDOM}"
echo "Add support for multiarch"
# See https://docs.docker.com/build/building/multi-platform/#install-qemu-manually
# We use QEMU for non arm platforms using the golang-crossbuild
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx ls
echo 'Create builder'
docker buildx create --name "${BUILDER_NAME}"
docker buildx use "${BUILDER_NAME}"
docker buildx inspect --bootstrap
echo 'Build Docker image'
docker buildx build --progress=plain --platform "${BUILDPLATFORM}" --push $*
================================================
FILE: .buildkite/scripts/common.sh
================================================
#!/usr/bin/env bash
set -euo pipefail
REPO="golang-crossbuild"
WORKSPACE="$(pwd)"
BIN="${WORKSPACE}/bin"
HW_TYPE="$(uname -m)"
PLATFORM_TYPE="$(uname)"
TMP_FOLDER="tmp.${REPO}"
if [[ -z "${GOLANG_VERSION-""}" ]]; then
export GOLANG_VERSION=$(cat "${WORKSPACE}/.go-version")
fi
add_bin_path() {
echo "Adding PATH to the environment variables..."
create_bin
export PATH="${PATH}:${BIN}"
}
with_go() {
local go_version="${1}"
echo "Setting up the Go environment..."
create_bin
check_platform_architecture
retry 5 curl -sL -o ${BIN}/gvm "https://github.com/andrewkroh/gvm/releases/download/v0.6.0/gvm-${PLATFORM_TYPE}-${arch_type}"
export PATH="${PATH}:${BIN}"
chmod +x ${BIN}/gvm
eval "$(gvm "$go_version")"
go version
which go
export PATH="${PATH}:$(go env GOPATH):$(go env GOPATH)/bin"
}
with_mage() {
local install_packages=(
"github.com/magefile/mage"
"github.com/elastic/go-licenser"
"golang.org/x/tools/cmd/goimports"
"github.com/jstemmer/go-junit-report"
"gotest.tools/gotestsum"
)
create_bin
for pkg in "${install_packages[@]}"; do
go install "${pkg}@latest"
done
}
create_bin() {
if [[ ! -d "${BIN}" ]]; then
mkdir -p ${BIN}
fi
}
check_platform_architecture() {
# for downloading the GVM and Terraform packages
case "${HW_TYPE}" in
"x86_64")
arch_type="amd64"
;;
"aarch64")
arch_type="arm64"
;;
"arm64")
arch_type="arm64"
;;
*)
echo "The current platform/OS type is unsupported yet"
;;
esac
}
retry() {
local retries=$1
shift
local count=0
until "$@"; do
exit=$?
wait=$((2 ** count))
count=$((count + 1))
if [ $count -lt "$retries" ]; then
>&2 echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
sleep $wait
else
>&2 echo "Retry $count/$retries exited $exit, no more retries left."
return $exit
fi
done
return 0
}
unset_secrets () {
for var in $(printenv | sed 's;=.*;;' | sort); do
if [[ "$var" == *_SECRET || "$var" == *_TOKEN ]]; then
unset "$var"
fi
done
}
cleanup() {
echo "Deleting temporary files..."
rm -rf ${BIN}/${TMP_FOLDER}.*
echo "Done."
}
tag_Exists() {
local tag=$1
local url=https://api.github.com/repos/elastic/${REPO}/releases/tags/${tag}
local status=$(retry 3 curl -s -o /dev/null -w "%{http_code}" -u ${GITHUB_TOKEN_SECRET}:x-oauth-basic ${url})
if [ "${status}" == "200" ]; then
echo true
else
echo false
fi
}
check_is_arm() {
if [[ ${HW_TYPE} == "aarch64" || ${HW_TYPE} == "arm64" ]]; then
is_arm="-arm"
else
is_arm=""
fi
}
================================================
FILE: .buildkite/scripts/llvm-apple/build.sh
================================================
#!/usr/bin/env bash
# This script builds the Docker images but does not push them to a registry.
# Env variables:
# - RELEASE: If set, indicates that this is a production release and images should be name to production. For manual releases
# - GOLANG_VERSION: Version of Go to use for the build. Defaults to the value in .buildkite/pipeline.yml.
# - MAKEFILE: Path to the Makefile to use.
# - STAGING_IMAGE: Docker repository to use for staging images.
set -euo pipefail
source .buildkite/scripts/common.sh
makefile=${1}
add_bin_path
with_go "${GOLANG_VERSION}"
with_mage
# if RELEASE is not set then set REPOSITORY to STAGING_IMAGE
if [[ -z "${RELEASE:-}" ]]; then
export REPOSITORY="${STAGING_IMAGE}"
fi
retry 3 make -C "${makefile}" build GS_BUCKET_PATH=golang-crossbuild-ci-internal
echo "--- List Docker images"
docker images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}"
================================================
FILE: .buildkite/scripts/llvm-apple/publish.sh
================================================
#!/usr/bin/env bash
# Env variables:
# - RELEASE: If set, indicates that this is a production release and images should be pushed to production. For manual releases
# - MAKEFILE: Path to the Makefile to use.
# - STAGING_IMAGE: Docker repository to use for staging images.
set -euo pipefail
source .buildkite/scripts/common.sh
makefile=${1}
add_bin_path
# if RELEASE is not set then set REPOSITORY to STAGING_IMAGE
if [[ -z "${RELEASE:-}" ]]; then
export REPOSITORY="${STAGING_IMAGE}"
fi
retry 3 make -C ${makefile} push
================================================
FILE: .buildkite/scripts/llvm-fpm/build_and_publish.sh
================================================
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common.sh
makefile=${1}
add_bin_path
with_go "${GOLANG_VERSION}"
with_mage
retry 3 make -C "${makefile}" build GS_BUCKET_PATH=golang-crossbuild-ci-internal
echo "--- List Docker images"
docker images --format "table {{.Repository}}:{{.Tag}}\t{{.Size}}"
================================================
FILE: .buildkite/scripts/post-release.sh
================================================
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common.sh
TAG="v$1"
TAG_EXISTS=$(tag_Exists ${TAG})
set_git_config() {
git config user.name "${GITHUB_USERNAME}"
git config user.email "${GITHUB_EMAIL}"
}
tag_commit() {
echo "Tagging commit ${BUILDKITE_COMMIT}"
git tag -a -m "${BUILDKITE_COMMIT}" "${TAG}"
}
git_push_with_auth() {
echo "Pushing tag ${TAG}"
retry 3 git push https://${GITHUB_USERNAME}:${GITHUB_TOKEN_SECRET}@github.com/elastic/golang-crossbuild.git ${TAG}
}
if [[ "${TAG_EXISTS}" == true ]]; then
message="Tag '$TAG' already exists! Exiting Post-release stage."
echo "$message"
buildkite-agent annotate "$message" --style 'warning' --context 'ctx-warn'
# This should return any error but skip the release.
exit 0
fi
set_git_config
tag_commit
git_push_with_auth
buildkite-agent annotate "Tag '$TAG' has been created." --style 'success' --context 'ctx-success'
================================================
FILE: .buildkite/scripts/publish.sh
================================================
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/common.sh
MAKEFILE=${1}
check_is_arm
add_bin_path
retry 3 make -C go -f "${MAKEFILE}" push"${is_arm}"
================================================
FILE: .buildkite/scripts/validate-go-version.sh
================================================
#!/usr/bin/env bash
set -euo pipefail
go_version=$(cat .go-version)
if grep -q "VERSION\s*:=\s*${go_version}" go/Makefile.common ; then
echo "Go version ${go_version} is consistent between .go-version and go/Makefile.common"
exit 0
fi
echo "Go version mismatch detected!"
echo " .go-version: ${go_version}"
echo " go/Makefile.common: $(grep '^VERSION' go/Makefile.common)"
exit 1
================================================
FILE: .editorconfig
================================================
# See: http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.yml]
indent_style = space
indent_size = 2
[Dockerfile]
indent_style = space
indent_size = 2
[Makefile]
indent_style = tab
================================================
FILE: .github/CODEOWNERS
================================================
* @elastic/elastic-agent-control-plane
# Ownership of CI or related files by the Ingest Eng Prod team
/.buildkite @elastic/observablt-ci
/catalog-info.yaml @elastic/observablt-ci
================================================
FILE: .github/actions/bump-golang/action.yml
================================================
---
name: common build tasks
inputs:
branch:
description: 'What branch'
required: true
go-minor:
description: 'What Go minor version ([0-9]+.[0.9]+)'
required: true
command:
description: 'What updatecli command'
default: 'apply'
required: false
slack-message:
description: 'Slack message if failure'
required: false
default: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @agent-team please look what's going on <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>"
slack-channel-id:
description: 'Slack channel ID'
required: false
default: "#ingest-notifications"
slack-bot-token:
description: 'Specify the slack bot token.'
required: true
github-token:
description: "The GitHub access token."
required: true
runs:
using: "composite"
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
- uses: elastic/oblt-actions/updatecli/run@v1
with:
command: ${{ env.COMMAND }} --config ./.github/updatecli.d/
version-file: .updatecli-version
env:
COMMAND: ${{ inputs.command }}
BRANCH: ${{ inputs.branch }}
GO_MINOR: ${{ inputs.go-minor }}
GITHUB_TOKEN: ${{ inputs.github-token }}
- uses: elastic/oblt-actions/slack/send@v1
if: failure()
with:
bot-token: ${{ inputs.slack-bot-token }}
channel-id: ${{ inputs.slack-channel-id }}
message: ${{ inputs.slack-message }}
================================================
FILE: .github/dependabot.yml
================================================
---
version: 2
updates:
# GitHub actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
time: "22:00"
groups:
github-actions:
patterns:
- "*"
# GitHub composite actions
- package-ecosystem: "github-actions"
directories:
- "/.github/actions/bump-golang"
- "/.github/workflows"
schedule:
interval: "weekly"
day: "sunday"
time: "22:00"
groups:
github-actions:
patterns:
- "*"
================================================
FILE: .github/release-drafter.yml
================================================
name-template: 'v$RESOLVED_VERSION 🌈'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bug'
- title: '📚 Documentation'
labels:
- 'docs'
- 'question'
- title: '🧰 Maintenance'
label:
- 'chore'
- 'ci'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
template: |
## Go $RESOLVED_VERSION
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armel-debian12(-fips)?` - linux/armv5, linux/armv6
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf-debian9(-fips)?` - linux/armv7
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf-debian10(-fips)?` - linux/armv7
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf-debian11(-fips)?` - linux/armv7
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf-debian12(-fips)?` - linux/armv7
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-armhf(-fips)?` - linux/armv7
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-arm-debian9(-fips)?` - linux/arm64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-arm-debian10(-fips)?` - linux/arm64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-arm-debian11(-fips)?` - linux/arm64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-arm-debian12(-fips)?` - linux/arm64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian7(-fips)?`
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian9(-fips)?`
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian10(-fips)?`
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian11(-fips)?`
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base-debian12(-fips)?`
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-base(-fips)?`
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-arm64-debian10(-fips)?` - darwin/arm64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-arm64-debian11(-fips)?` - darwin/arm64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-arm64-debian12(-fips)?` - darwin/arm64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-debian9(-fips)?` - darwin/amd64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-debian10(-fips)?` - darwin/amd64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-debian11(-fips)?` - darwin/amd64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin-debian12(-fips)?` - darwin/amd64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-darwin(-fips)?` - darwin/amd64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian7(-fips)?` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian9(-fips)?` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian10(-fips)?` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian11(-fips)?` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main-debian12(-fips)?` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-main(-fips)?` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-mips-debian12(-fips)?` - linux/mips64, linux/mips64el
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-ppc-debian12(-fips)?` - linux/ppc64, linux/ppc64le
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-s390x-debian12(-fips)?` - linux/s390x
- `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-windows-arm64-debian12(-fips)?` - linux/arm64, windows/arm64
### Changes
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
================================================
FILE: .github/updatecli.d/bump-go-version.sh
================================================
#!/usr/bin/env bash
#
# Given the Microsoft Golang release version this script will bump the version.
#
# This script is executed by the automation we are putting in place
#
# NOTE:
# * sha256 is retrieved from https://pkg.go.dev/golang.org/x/website/internal/dl?utm_source=godoc
# * sha256 is retrieved from https://github.com/microsoft/go/releases/download/v${GO_RELEASE_VERSION}/assets.json
# * https://aka.ms/golang/release/latest/go${MAJOR_MINOR_PATCH_VERSION}.assets.json is not used because it does not fail if version is not available
#
# Parameters:
# $1 -> the Microsoft Golang release version to be bumped. Mandatory.
#
set -euo pipefail
MSG="parameter missing."
GO_RELEASE_VERSION=${1:?$MSG}
OS=$(uname -s| tr '[:upper:]' '[:lower:]')
if [ "${OS}" == "darwin" ] ; then
SED="sed -i .bck"
else
SED="sed -i"
fi
# Process the GO_RELEASE_VERSION to extract major, minor, patch and security versions
MAJOR_MINOR_PATCH_VERSION=${GO_RELEASE_VERSION%-*}
SECURITY_VERSION="-${GO_RELEASE_VERSION##*-}"
# Gather golang/go sha256 values
GOLANG_DOWNLOAD_SHA256_ARM=$(curl -s -L https://golang.org/dl/\?mode\=json | jq -r ".[] | select( .version | contains(\"go${GO_RELEASE_VERSION}\")) | .files[] | select (.filename | contains(\"go${GO_RELEASE_VERSION}.linux-arm64.tar.gz\")) | .sha256")
GOLANG_DOWNLOAD_SHA256_AMD=$(curl -s -L https://golang.org/dl/\?mode\=json | jq -r ".[] | select( .version | contains(\"go${GO_RELEASE_VERSION}\")) | .files[] | select (.filename | contains(\"go${GO_RELEASE_VERSION}.linux-amd64.tar.gz\")) | .sha256")
# Gather microsoft/go sha256 values
MSFT_URL="https://github.com/microsoft/go/releases/download/v${GO_RELEASE_VERSION}/assets.json"
if ! curl --output /dev/null -L --silent --head --fail "$MSFT_URL"; then
echo "No Microsoft Golang release found for version ${GO_RELEASE_VERSION}"
exit 1
fi
MSFT_DOWNLOAD_METADATA=$(curl -s -L "$MSFT_URL")
MSFT_DOWNLOAD_SHA256_ARM=$(echo $MSFT_DOWNLOAD_METADATA | jq -r ".arches[] | select( .env.GOOS == \"linux\") | select( .env.GOARCH == \"arm64\") | .sha256")
MSFT_DOWNLOAD_SHA256_AMD=$(echo $MSFT_DOWNLOAD_METADATA | jq -r ".arches[] | select( .env.GOOS == \"linux\") | select( .env.GOARCH == \"amd64\") | .sha256")
## As long as https://golang.org/dl/?mode=json supports only 2 major versions
## and there is a new major release, then it's required to parse https://golang.org/dl
## see https://github.com/elastic/golang-crossbuild/pull/389/commits/d0af04f97a2381630ea5e8da5a99f50cf27856a0
if [ -z "$GOLANG_DOWNLOAD_SHA256_ARM" ] ; then
GOLANG_DOWNLOAD_SHA256_ARM=$(curl -s -L https://golang.org/dl | grep "go${MAJOR_MINOR_PATCH_VERSION}.linux-arm64.tar.gz" -A 5 | grep "<tt>" | sed 's#.*<tt>##g' | sed 's#</t.*##g')
fi
if [ -z "$GOLANG_DOWNLOAD_SHA256_AMD" ] ; then
GOLANG_DOWNLOAD_SHA256_AMD=$(curl -s -L https://golang.org/dl | grep "go${MAJOR_MINOR_PATCH_VERSION}.linux-amd64.tar.gz" -A 5 | grep "<tt>" | sed 's#.*<tt>##g' | sed 's#</t.*##g')
fi
find "go" -type f -name Dockerfile.tmpl -print0 |
while IFS= read -r -d '' line; do
if echo "$line" | grep -q 'arm' ; then
${SED} -E -e "s#(ARG GOLANG_DOWNLOAD_SHA256)=.+#\1=${GOLANG_DOWNLOAD_SHA256_ARM}#g" "$line"
if [ -n "$MSFT_DOWNLOAD_SHA256_ARM" ]; then
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_ARM}#g" "$line"
fi
else
${SED} -E -e "s#(ARG GOLANG_DOWNLOAD_SHA256)=.+#\1=${GOLANG_DOWNLOAD_SHA256_AMD}#g" "$line"
if [ -n "$MSFT_DOWNLOAD_SHA256_AMD" ]; then
${SED} -E -e "s#(ARG MSFT_DOWNLOAD_SHA256)=.+#\1=${MSFT_DOWNLOAD_SHA256_AMD}#g" "$line"
fi
fi
if [ -n "$SECURITY_VERSION" ]; then
${SED} -E -e "s#(ARG SECURITY_VERSION)=.*#\1=${SECURITY_VERSION}#g" "$line"
fi
${SED} -E -e "s#(ARG VERSION)=.+#\1=${MAJOR_MINOR_PATCH_VERSION}#g" "$line"
done
if git diff --quiet ; then
# No modifications – exit successfully but keep stdout empty to that updatecli is happy
exit 0
else
echo "Update Go version ${GO_RELEASE_VERSION}"
git --no-pager diff
fi
================================================
FILE: .github/updatecli.d/bump-golang.yml
================================================
---
name: Bump golang-version to latest version
pipelineid: 'bump-golang-version-{{ requiredEnv "BRANCH" }}'
scms:
githubConfig:
kind: github
spec:
user: '{{ requiredEnv "GITHUB_ACTOR" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
owner: elastic
repository: golang-crossbuild
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
branch: '{{ requiredEnv "BRANCH" }}'
commitusingapi: true
actions:
default:
title: '[Automation] Bump Golang version to {{ source "latestMicrosoftGoVersion" }}'
kind: github/pullrequest
scmid: githubConfig
spec:
automerge: false
labels:
- automation
- dependencies
- backport-skip
description: |
See [changelog](https://github.com/golang/go/issues?q=milestone%3AGo{{ source "golangVersion" }}+label%3ACherryPickApproved) for {{ source "golangVersion" }}
sources:
minor:
name: Get minor version
kind: shell
transformers:
- findsubmatch:
pattern: '^\d+.(\d+)'
captureindex: 1
spec:
command: echo {{ requiredEnv "GO_MINOR" }}
latestMicrosoftGoVersion:
name: Get Latest Microsoft Go Release
kind: githubrelease
dependson:
- minor
transformers:
- trimprefix: v
spec:
owner: microsoft
repository: go
token: '{{ requiredEnv "GITHUB_TOKEN" }}'
username: '{{ requiredEnv "GITHUB_ACTOR" }}'
versionfilter:
kind: regex
pattern: v1\.{{ source "minor" }}\.(\d*)(-\d*)$
golangVersion:
# NOTE: FIPS images need the Microsoft version.
name: Get the Microsoft version of Golang, as it comes out a little later
dependson:
- latestMicrosoftGoVersion
kind: shell
transformers:
- findsubmatch:
pattern: '^(\d+.\d+.\d+)-(\d+)'
captureindex: 1
spec:
command: echo {{ source "latestMicrosoftGoVersion" }}
conditions:
dockerTag:
name: Is docker image golang:{{ source "golangVersion" }} published
kind: dockerimage
spec:
image: golang
tag: '{{ source "golangVersion" }}'
sourceid: golangVersion
is:
name: Is version '{{ source "golangVersion" }}' not updated in 'go/Makefile.common'?
disablesourceinput: true
scmid: githubConfig
kind: file
spec:
file: go/Makefile.common
line: 5
content: VERSION := {{ source `golangVersion` }}
failwhen: true
targets:
update-go-version:
name: "Update .go-version"
sourceid: golangVersion
scmid: githubConfig
kind: file
spec:
content: '{{ source "golangVersion" }}'
file: .go-version
matchpattern: '\d+.\d+.\d+'
update-go-makefile.common:
name: "Update go/Makefile.common"
sourceid: golangVersion
scmid: githubConfig
kind: file
spec:
content: '{{ source "golangVersion" }}'
file: go/Makefile.common
matchpattern: '\d+.\d+.\d+'
update-go-versions:
name: 'Update go version {{ source "latestMicrosoftGoVersion" }}'
kind: shell
sourceid: latestMicrosoftGoVersion
scmid: githubConfig
spec:
command: .github/updatecli.d/bump-go-version.sh
environments:
- name: PATH
================================================
FILE: .github/workflows/bump-golang-previous.yml
================================================
---
name: bump-golang-previous
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * 1-6'
permissions:
contents: read
jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/bump-golang
with:
# NOTE: when a new golang version please update me with 1.<go-version-1>
branch: '1.25'
# NOTE: when a new golang version please update me with 1.<go-version-1>
go-minor: '1.25'
command: '--experimental apply'
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .github/workflows/bump-golang.yml
================================================
---
name: bump-golang-main
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * 1-6'
permissions:
contents: read
jobs:
bump:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/bump-golang
with:
branch: 'main'
# NOTE: when a new golang version please update me with 1.<go-version>
go-minor: '1.26'
command: '--experimental apply'
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .github/workflows/catalog-info.yml
================================================
---
name: catalog-info
on:
pull_request:
branches:
- main
paths:
- 'catalog-info.yaml'
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v6
- uses: elastic/oblt-actions/elastic/validate-catalog@v1
================================================
FILE: .github/workflows/release-drafter.yml
================================================
name: Release Drafter
on:
push:
tags:
- v*.*
permissions:
contents: read
jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: version
id: version
run: |
tag=${GITHUB_REF/refs\/tags\//}
version=${tag#v}
echo "::set-output name=version::${version}"
- uses: release-drafter/release-drafter@v7
with:
version: ${{ steps.version.outputs.version }}
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .gitignore
================================================
*.iml
*.swp
*.o
.idea
.vagrant
.vscode
_obj
Dockerfile
.status.*
*.bck
npcap/lib/*.exe
================================================
FILE: .go-version
================================================
1.26.2
================================================
FILE: .mergify.yml
================================================
queue_rules:
- name: default
merge_method: squash
conditions:
- check-success=buildkite/golang-crossbuild
- check-success=CLA
pull_request_rules:
- name: automatic approval for automated pull requests with golang bump updates
conditions:
- check-success=buildkite/golang-crossbuild
- label=automation
- files~=^go/Makefile.common
actions:
review:
type: APPROVE
message: Automatically approving mergify
- name: ask to resolve conflict
conditions:
- -merged
- -closed
- conflict
actions:
comment:
message: |
This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/
```
git fetch upstream
git checkout -b {{head}} upstream/{{head}}
git merge upstream/{{base}}
git push upstream {{head}}
```
- name: close automated pull requests with bump updates if any conflict
conditions:
- -merged
- -closed
- conflict
- label=automation
actions:
close:
message: |
This pull request has been automatically closed by Mergify.
There are some other up-to-date pull requests.
- name: squash and merge updatecli PRs after CI passes with golang bump updates
conditions:
- label=automation
- head~=^updatecli
- -conflict
- files~=^go/Makefile.common
actions:
queue:
name: default
- name: notify the backport has not been merged yet
conditions:
- -merged
- -closed
- author=mergify[bot]
- "#check-success>0"
- schedule=Mon-Mon 06:00-10:00[Europe/Paris]
actions:
comment:
message: |
This pull request has not been merged yet. Could you please review and merge it @{{ assignee | join(', @') }}? 🙏
- name: notify the backport policy
conditions:
- -label~=^backport
- base=main
- -merged
- -closed
actions:
comment:
message: |
This pull request does not have a backport label. Could you fix it @{{author}}? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:
* `backport-v./d./d` is the label to automatically backport to the `1./d` branch. `/d` is the digit
**NOTE**: `backport-skip` has been added to this pull request.
label:
add:
- backport-skip
- name: remove-backport label
conditions:
- label~=backport-v
- -merged
- -closed
actions:
label:
remove:
- backport-skip
- name: backport patches to 1.16 branch
conditions:
- merged
- label=backport-v1.16
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.16"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.17 branch
conditions:
- merged
- label=backport-v1.17
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.17"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.18 branch
conditions:
- merged
- label=backport-v1.18
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.18"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.19 branch
conditions:
- merged
- label=backport-v1.19
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.19"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.20 branch
conditions:
- merged
- label=backport-v1.20
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.20"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.21 branch
conditions:
- merged
- label=backport-v1.21
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.21"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.22 branch
conditions:
- merged
- label=backport-v1.22
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.22"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.23 branch
conditions:
- merged
- label=backport-v1.23
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.23"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.24 branch
conditions:
- merged
- label=backport-v1.24
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.24"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
- name: backport patches to 1.25 branch
conditions:
- merged
- label=backport-v1.25
actions:
backport:
assignees:
- "{{ author }}"
branches:
- "1.25"
labels:
- "backport"
title: "[{{ destination_branch }}](backport #{{ number }}) {{ title }}"
================================================
FILE: .updatecli-version
================================================
v0.109.0
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: Makefile
================================================
include Makefile.common
TARGETS=go
ARM_TARGETS=go
build: status=".status.build"
build:
@echo '0' > ${status}
@$(foreach var,$(TARGETS), \
$(MAKE) -C $(var) $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian7 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian8 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian10 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian11 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian12 $@ || echo '1' > ${status})
@make -C fpm $@ || echo '1' > ${status}
exit $$(cat ${status})
build-arm: status=".status.build.arm"
build-arm:
echo '0' > ${status}
$(foreach var,$(ARM_TARGETS), \
$(MAKE) -C $(var) $@ || echo '1' > ${status};\
$(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status})
make -C fpm $@ || echo '1' > ${status}
exit $$(cat ${status})
# Requires login at https://docker.elastic.co:7000/.
push: status=".status.push"
push:
@echo '0' > ${status}
@$(foreach var,$(TARGETS), \
$(MAKE) -C $(var) $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian7 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian8 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian10 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian11 $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian12 $@ || echo '1' > ${status})
@make -C fpm $@ || echo '1' > ${status}
exit $$(cat ${status})
push-arm: status=".status.push.arm"
push-arm:
@echo '0' > ${status}
@$(foreach var,$(ARM_TARGETS), \
$(MAKE) -C $(var) $@ || echo '1' > ${status}; \
$(MAKE) -C $(var) -f Makefile.debian9 $@ || echo '1' > ${status})
@make -C fpm $@ || echo '1' > ${status}
exit $$(cat ${status})
.PHONY: build build-arm push push-arm
================================================
FILE: Makefile.common
================================================
REPOSITORY ?= docker.elastic.co/beats-dev
VCS_REF := $(shell git rev-parse HEAD)
VCS_URL := https://github.com/elastic/golang-crossbuild
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
.DEFAULT_GOAL := build
NPCAP_VERSION := 1.87
NPCAP_FILE := npcap-$(NPCAP_VERSION)-oem.exe
SUFFIX_NPCAP_VERSION := -npcap-$(NPCAP_VERSION)
NPCAP_REPOSITORY := docker.elastic.co/observability-ci
GS_BUCKET_PATH ?= golang-crossbuild-ci-internal
# Requires login at google storage.
copy-npcap:
ifeq ($(CI),true)
@gcloud storage cp gs://$(GS_BUCKET_PATH)/private/$(NPCAP_FILE) ../npcap/lib/$(NPCAP_FILE)
else
@echo 'Only available if running in the CI'
endif
# Requires login at google storage.
copy-sdks:
ifeq ($(CI),true)
@gcloud storage cp gs://$(GS_BUCKET_PATH)/sdks . --recursive
else
@echo 'Only available if running in the CI'
endif
push:
$(MAKE) atomic-push
push-arm:
@echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)"
@docker push "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)"
.PHONY: push push-arm
# Requires login at https://docker.elastic.co:7000/.
atomic-push:
@echo ">> Pushing $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)"
@docker push "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)"
================================================
FILE: NPCAP.md
================================================
# NPCAP
If you'd like to bump the npcap version please follow the below steps:
1) Update `NPCAP_VERSION` value in the `Makefile`.
* **NOTE**: Make sure the PR adding this is back-ported to the Go versions required by the Packetbeat CrossBuild target in [the mage file](https://github.com/elastic/beats/blob/main/x-pack/packetbeat/magefile.go). This is specified in the beats `.go-version` file.
2) Download the new artifact.
3) Upload the artifact to `gs://golang-crossbuild-ci-internal/private`.
* **NOTE**: This particular Google Bucket can be accessible only by Elasticians who have got access to the Google project called `elastic-observability-ci`. It's managed thorugh some Terraform code.
Credentials to the artifact service can be found in the `APM-Shared` folder in the password management tool.
4) After you've updated the npcap version in golang-crossbuild, make sure to change the npcap version specified in the [packetbeat magefile](https://github.com/elastic/beats/blob/main/x-pack/packetbeat/magefile.go)
## Backports
If you'd like to backport any NCAP_VERSION to any existing golang-crosbuild version, then you need to:
* Create a branch called `major.minor.patch.x` for the `vmajor.minor.patch` tag (where `x` is a literal "x" character, not a number placeholder)
* Cherry-pick your PR, you can use `Mergifyio`, with `@mergifyio backport major.minor.path.x`
* Then the new PR that has been created can be merged when all the GitHub checks have passed.
For instance, if ncap version needs to be updated in `1.20.8` then:
```bash
git checkout v1.20.8
git checkout -b 1.20.8.x
git push upstream 1.20.8.x
```
Afterwards you can then backport your PR with ncap changes with the GitHub command `@Mergifyio backport 1.20.8.x`,
see https://github.com/elastic/golang-crossbuild/pull/315 that illustrates this example.
https://github.com/elastic/golang-crossbuild/pull/320 is the one that has been created with the backport targeting
`1.20.8.x`. Automatically when it gets merged, the golang-crossbuild:1.20.8 will be regenerated and contain the
new ncap changes.
================================================
FILE: README.md
================================================
| | main | 1.25 |
|-------------------|------|-|
| golang-crossbuild |[](https://buildkite.com/elastic/golang-crossbuild/builds?branch=main)|[](https://buildkite.com/elastic/golang-crossbuild/builds?branch=1.25)|
| llvm-apple |[](https://buildkite.com/elastic/llvm-apple/builds?branch=main)|[](https://buildkite.com/elastic/llvm-apple/builds?branch=1.25)|
| fpm |[](https://buildkite.com/elastic/fpm/builds?branch=main)|[](https://buildkite.com/elastic/fpm/builds?branch=1.25)|
# golang-crossbuild Docker images
This repository contains Dockerfiles for cross building Go binaries for various platforms.
The aim is to provide a simple way to build Go binaries for multiple platforms without having to install and configure cross compilers on your host machine.
To do that the project provides a set of Docker images that can be used to build Go binaries for the following platforms:
* linux/amd64
* linux/arm
* linux/armel
* linux/armhf
* linux/arm64
* linux/mips
* linux/mipsle
* linux/mips64
* linux/ppc64
* linux/ppc64le
* linux/s390x
* windows/amd64
* darwin/amd64
* darwin/arm64
The Docker images are based on Debian and the cross compilers are installed using the crossbuild-essential package.
Each architecture has its own folder with the files needed to build the Docker image for that architecture.
Each architecture has its own Dockerfile to build a Docker image for that architecture.
Each architecture Dockerfile installs the crossbuild-essential package for that architecture and the libraries needed to build our binaries.
These Dockerfiles are generated files from `Dockerfile.tmpl` template file that is in the architectures folder.
This template is processed using a Makefile that is in the architectures folder.
Each architecture folder has a `roofs` folder that contains the files that will be copied to the Docker image in the root folder.
In `rootfs` we have the `compolers.yml` file that contains the list of compilers that will be installed in the Docker image.
Each Docker image has a basic compilation test that is executed when the image is built. This test uses `rootfs/helloworld.c` file to compile a simple C program and verify the architecture of the result binary.
The compiler used to build the binaries is LLVM.
Some of the Docker images are build for the amd64 and arm64 architectures, this allow to run the Docker images in linux/amd64, linux/arm64, darwin/amd64, and darwin/arm64. This is done using the `.buildkite/scripts/buildx.sh` command.
The Docker images are tagged using the following format:
* `docker.elastic.co/beats-dev/golang-crossbuild:<go-version>-<arch>-<debian-version>`
For the latest version of the images based on the latest Debian and Go versions, the following tag is also used:
* `docker.elastic.co/beats-dev/golang-crossbuild:<go-version>-<arch>`
## Build tags
The tags match with the Golang version, and for each supported version there is a release in https://github.com/elastic/golang-crossbuild/releases.
Replace `<GOLANG_VERSION>` with the version you would like to use, for instance: `1.17.1`
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-arm` - linux/arm64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-armel` - linux/armv5, linux/armv6
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-armhf` - linux/armv7
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-base`
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-darwin` - darwin/amd64 (MacOS 10.11, MacOS 10.14)
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian7` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian8` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian9` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian10` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian11` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-main-debian12` - linux/i386, linux/amd64, windows/amd64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-mips-debian11` - linux/mips64, linux/mips64el
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-mips-debian12` - linux/mips64, linux/mips64el
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-mips32` - linux/mips, linux/mipsle **NOTE**: it does not exist from Golang versions > `1.18.5`/`1.17.12`.
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-ppc-debian12` - linux/ppc64, linux/ppc64le
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-s390x-debian11` - linux/s390x
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-s390x-debian12` - linux/s390x
### glibc
* **Debian7** uses `glibc 2.13` so the resulting binaries (if dynamically linked) have greater compatibility.
* **Debian8** uses `glibc 2.19`.
* **Debian9** uses `glibc 2.24`.
* **Debian10** uses `glibc 2.28`.
* **Debian11** uses `glibc 2.31`.
## Old Build Tags
Until Golang version 1.15
| Description | Tags for 1.10 | Tags for 1.11 | Tags for 1.12 | Tags for 1.13 | Tags for 1.14 | Tags for 1.15 |
| ------------- | -----| ------- | ----- | ------ | ------ | ------ |
| linux/{amd64,386} and windows/{amd64,386} | `1.10.8-main` | `1.11.13-main` | `1.12.12-main` | `1.13.12-main` | `1.14.15-main` | `1.15.14-main` |
| linux/{armv5,armv6,armv7} | `1.10.8-arm` | `1.11.13-arm` | `1.12.12-arm` | `1.13.12-arm` | `1.14.15-arm` | `1.15.14-arm` |
| linux/arm64 | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |
| linux/{armv5,armv6} | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |
| linux/{armv7} | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |
| darwin/{386} | `1.10.8-darwin` | `1.11.13-darwin` | `1.12.12-darwin` | `1.13.12-darwin` | `1.14.15-darwin` | `1.15.14-darwin` |
| darwin/{amd64} | `1.10.8-darwin` | `1.11.13-darwin` | `1.12.12-darwin` | `1.13.12-darwin` | `1.14.15-darwin` | `1.15.14-darwin` |
| linux/{ppc64,ppc64le} | `1.10.8-ppc` | `1.11.13-ppc` | `1.12.12-ppc` | `1.13.12-ppc` | `1.14.15-ppc` | `1.15.14-ppc` |
| linux/{mips,mipsle,mips64,mips64le} | `1.10.8-mips` | `1.11.13-mips` | `1.12.12-mips` | `1.13.12-mips` | `1.14.15-mips` |
| linux/{mips64,mips64le} | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |
| linux/{mips,mipsle} | **See above** | **See above** | **See above** | **See above** | **See above** | **See above** |
| linux/s390x | `1.10.8-s390x` | `1.11.13-s390x` | `1.12.12-s390` | `1.13.12-s390` | `1.14.15-s390` | `1.15.14-s390` |
| linux/{amd64,386} and windows/{amd64,386} (Debian 7 (see **below**)) |`1.10.8-main-debian7` | `1.11.13-main-debian7` | `1.12.12-main-debian7` | `1.13.12-main-debian7` | `1.14.15-main-debian7` | `1.15.14-main-debian7` |
| linux/{amd64,386} and windows/{amd64,386} (Debian 8 (see **below**)) | `1.10.8-main-debian8` | `1.11.13-main-debian8` | `1.12.12-main-debian8` | `1.13.12-debian8` | `1.14.15-main-debian8` | `1.15.14-main-debian8` |
| linux/{amd64,386} and windows/{amd64,386} (Debian 9 (see **below**)) | NA | NA | NA | NA | NA | `1.15.14-main-debian9` |
| linux/{amd64,386} and windows/{amd64,386} (Debian 10 (see **below**)) | NA | NA | NA | NA | NA | `1.15.14-main-debian10` |
| linux/arm64 (Debian 9 (see **below**)) | NA | NA | NA | NA | NA | `1.15.14-base-arm-debian9` |
### glibc
* **Debian7** uses `glibc 2.13` so the resulting binaries (if dynamically linked) have greater compatibility.
* **Debian8** uses `glibc 2.19`.
* **Debian9** uses `glibc 2.24`.
* **Debian10** uses `glibc 2.28`.
## Makefiles
There are several Makefiles in the profect across the different folders.
The Makefile in the root folder is used to build the Docker images for the different architectures,
it triggers the build of all Docker images for all architectures and Debian versions supported.
The file `go/Makefile.common` is the default Makefile used to build the Docker images for the different architectures.
There is additional Makefile for each Debian version that is used to build the Docker images for that Debian version.
* `go/Makefile.debian7`
* `go/Makefile.debian8`
* `go/Makefile.debian9`
* `go/Makefile.debian10`
* `go/Makefile.debian11`
No all architectures are supported in all Debian versions, so the Makefile for each Debian version will only build the Docker images for the architectures that are supported in that Debian version.
On the Makefiles there are some variables to define the name of the Docker image, the version of the Docker image, the Debian version, and the suffix to use in the tag of the Docker image.
```make
NAME := golang-crossbuild
VERSION := 1.20.2
DEBIAN_VERSION ?= 9
SUFFIX := -$(shell basename $(CURDIR))
TAG_EXTENSION ?=
export DEBIAN_VERSION TAG_EXTENSION
DOCKER_CMD := docker build
```
In this example the name of the Docker image is `golang-crossbuild`, the go version is `1.20.2` that is uses as part of the tag, the Debian version is `9`, the suffix is `-debian9`, and the tag extension is empty. Also the `DOCKER_CMD` variable is used to define the command to use to build the Docker image, in this case `docker build`.
The tag is build using the following format:
```make
TAG := $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)
```
The common variables to all the Makefiles are defined at `Makefile.common` file.
To more information about the supported architextures and the correlation with comercial names,
you can check the [Debian Supported Architectures](https://wiki.debian.org/SupportedArchitectures) page.
To make and push the Docker images for all the architectures and default Debian version, you can run the following command:
```shell
make build push
```
To make and push the Docker images for all the architectures and Debian 10, you can run the following command:
```shell
make -C go -f Makefile.debian10 build push
```
Finally, to build a single Docker image for `arm` architecture and Debian 10, you can run the following command:
```shell
make -C go -f Makefile.debian10 build push IMAGES=arm
```
## Multiarch Docker images
Some of the Docker images are built for the amd64 and arm64 architectures, this allow to run the Docker images in linux/amd64, linux/arm64, darwin/amd64, and darwin/arm64. This is done using the `.buildkite/scripts/buildx.sh` command.
To choose if build a Docker image for amd64 and arm64 or only for amd64, The Makefiles check fot the value o `BUILDX` and `DOCKER_MULTIARCH` variables. In the target Makefile the `DOCKER_COMMAND` is replaced with the `.buildkite/scripts/buildx.sh` command.
```make
ifeq ($(DOCKER_MULTIARCH),1)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
endif
```
## Docker images dependencies
The Docker images depends on each other, so there is an order to build them.
The are two Docker images that are parent of all the other images, the `fpm` and the `go/llvm-apple`.
Anytime a new Debian version is released, the `fpm` and `go/llvm-apple` image needs to be updated to use the new Debian version.
The following diagram shows the dependencies between the Docker images.
```mermaid
stateDiagram-v2
[*] --> Debian
Debian --> fpm
Debian --> base
Debian --> base_arm
Debian --> llvm_apple
llvm_apple --> darwing_arm64
base --> arm
base --> armel
base --> armhf
base --> main
base --> darwin
base --> darwing_arm64
base --> mips
base --> mips32
base --> npcap
base --> ppc
base --> s390x
```
## Releasing
See [RELEASE.md](RELEASE.md) for the release process.
## FIPS Build
[Makefile.common](./go/Makefile.common) has an env var that can be used to create a FIPS compliant golang-crossbuild image:
```make
FIPS ?=
```
When this var is set to `"true"` the [microsoft/go](https://github.com/microsoft/go) will be used instead of the regular upstream go release.
Additionally the docker image will have the env vars `CGO_ENABLED=1` and `GOEXPERIMENT=systemcrypto` set to ensure binaries built within the crossbuild image are FIPS compliant by default.
## Packaging MacOS SDK
The osxcross repository used to cross compile for MacOSX has [instructions for packaging the SDK](https://github.com/tpoechtrager/osxcross#packaging-the-sdk).
The instructions for packaging the SDK on a Linux instance are:
1. Clone the [osxcross](https://github.com/tpoechtrager/osxcross) repo.
1. Install `clang`, `make`, `libssl-dev`, `lzma-dev`, `libxml2-dev`, `libbz2-dev`.
1. Download [Xcode from Apple](Download Xcode: https://developer.apple.com/download/more]).
1. Run `./tools/gen_sdk_package_pbzx.sh <xcode>.xip`.
## Usage Example
```shell
docker run -it --rm \
-v $GOPATH/src/github.com/user/go-project:/go/src/github.com/user/go-project \
-w /go/src/github.com/user/go-project \
-e CGO_ENABLED=1 \
docker.elastic.co/beats-dev/golang-crossbuild:1.16.7-armhf \
--build-cmd "make build" \
-p "linux/armv7"
```
This will execute your projects `make build` target. While executing the build
command the following variables with be added to the environment: GOOS, GOARCH,
GOARM, PLATFORM_ID, CC, and CXX.
## fpm Docker image
This Docker image install the [fpm](https://github.com/jordansissel/fpm) tool that is used to build packages.
## go/llvm-apple Docker image
The LLVM compiler present in Debian does not support arm64e architecture, so we need to build our own LLVM compiler to support this architecture.
The llvm-apple Docker image is based on [Apple LLVM fork](https://github.com/apple/llvm-project) and [osxcross](https://codeload.github.com/tpoechtrager/osxcross). The image build the LLVM compiler and configure the image to be able to cross compile for MacOSX.
LLVM need a SDK for macOS, the MacOSX-SDK used in the Docker image must be genarated from a MacOSX machine.
For the instructions to package the MacOS SDK see the [Packaging MacOS SDK](#packaging-macos-sdk) section.
## go/base Docker image
This Docker image is the base image for all the other Docker images, it contains the base packages fro cross compilation.
It is build for amd64 and arm64 architectures for Debian 9+.
In the folder you can find the `sources.list` file that contains the list of repositories to use to install the packages,
this file is different for each Debian version. In some cases, this file must point to `http://archive.debian.org/debian` instead of `http://deb.debian.org/debian` to be able to install the packages, this happens when the Debian version reach the end of life.
The base image is the one that install the `go` compiler, and the build tools for the rest of Docker images.
When a new version of go is released, the *Dockerimage.tmpl* files must be updated to install the new version.
## go/base-arm Docker image
The `base-arm` image is the base image to crossbuild `linux/arm64` binaries on `arm` hosts, it is build for Debian 7+.
This image is user to crosscompile in `linux/arm`.
It was replaced by the `base` image for Debian 9+ when we started to build multiarchitecture Docker images.
It could be removed in the future, it allow to `crosscompile` arm binaries in `linux/arm64` machines, that it is not needed because the native architecture is the same than the target architecture.
It was added to golang-crossbuild due limitations of the build system.
## go/main Docker image
The `main` image is the base image for the `amd64` architecture, it is build for Debian 7+.
It is used to cross compile for `linux/amd`, `linux/amd64`, `win/amd`, and `win/amd64`.
This Docker immage add two libraries to the `base` image, `libpcap` and `WpdPack` to be able to capture network packages on diferent OS.
Thes two libraries are precompiled and stored at https://storage.googleapis.com/golang-crossbuild-ci-internal/sdks.
## go/darwin Docker image
The `darwin` image is the base image for the MacOSX cross compilation, it is build for Debian 8+.
It can compiles for `darwin/amd` (Debian 10+), `darwin/amd64`, `darwin/arm64`, `darwin/arm64e`, and universal binaries.
This Docker image is based on the `base` image.
It uses [osxcross](https://codeload.github.com/tpoechtrager/osxcross) to configure the crosscompile for MacOSX.
This image require a MacOSX SDK to be installed in the Docker image,
for the instructions to package the MacOS SDK see the [Packaging MacOS SDK](#packaging-macos-sdk) section.
## go/darwin-arm64 Docker image
The `darwin-arm64` image is the base image for the MacOSX cross compilation, it is build for Debian 10+.
It can compiles for `darwin/amd64`, `darwin/arm64`, and `darwin/arm64e`, and universal binaries.
This Docker image is based on the `base` image.
It uses the `llvm-apple` image to cross compile for MacOSX.
The `darwin-arm64` can replace the `darwin` image in the future, it is faster to build and it does not need to build [osxcross](https://codeload.github.com/tpoechtrager/osxcross) and uses the official LLVM fork from Apple so it support enhacement for `darwin` architectures.
## go/arm Docker image
The `arm` image is the base image for the `arm64` architecture, it is build for Debian 9+.
It is used to cross compile for `linux/arm64`. This Docker image is based on the `base` image.
## go/armel Docker image
The `armel` image is the base image for the `armel` architecture, it is build for Debian 12+.
It is used to cross compile for `linux/armel`. This Docker image is based on the `base` image.
## go/armhf Docker image
The `armhf` image is the base image for the `armhf` architecture, it is build for Debian 9+.
It is used to cross compile for `linux/armhf`. This Docker image is based on the `base` image.
## go/mips Docker image
The `mips` image is the base image for the `mips` architecture, it is build for Debian 12+.
It is used to cross compile for `linux/mips`. This Docker image is based on the `base` image.
## go/mips32 Docker image
The `mips32` image is the base image for the `mips32` architecture, it is build for Debian 11+.
It is used to cross compile for `linux/mips32`. This Docker image is based on the `base` image.
## go/ppc Docker image
The `ppc` image is the base image for the `ppc` architecture, it is build for Debian 12+.
It is used to cross compile for `linux/ppc`. This Docker image is based on the `base` image.
## go/s390x Docker image
The `s390x` image is the base image for the `s390x` architecture, it is build for Debian 12+.
It is used to cross compile for `linux/s390x`. This Docker image is based on the `base` image.
## go/npcap Docker image
The `npcap` image is a placeholder for the `npcap` library, see [npcap](./NPCAP.md) for more information.
## Troubleshooting
### bzip2 issues
If the `gen_sdk_package_pbza.sh` script gives an error that reads:
```shell
Error while extracting archive:(Metadata): bzip2 support not compiled in. (Success)
```
A manual work-around is needed in order to create the SDK (other people have reported that installing `libbz2-dev` fixed this issue).
First edit `osxcross/tools/tools.sh` to remove the `trap` line from the `create_tmp_dir` function (currently line 264).
Then re-run `./tools/gen_sdk_package_pbzx.sh <xcode>.xip`.
Go to the tmp dir created in the build dir: `cd osxcross/build/tmp_<X>`.
Then run:
```shell
../../target/SDK/tools/bin/pbzx -n Content | cpio -i
cd ../..
XCODEDIR=osxcross/build/tmp_<X> ./tools/gen_sdk_package.sh
```
The SDK should be in the working directory.
The tmp dir can be safely deleted after this.
The SDKs should be uploaded into the `gs://golang-crossbuild-ci-internal/sdks` bucket on GCP (Google Cloud Platform).
This is accessible to authorized users in the `elastic-observability-ci` project [here](https://console.cloud.google.com/storage/browser/golang-crossbuild-ci-internal/sdks).
================================================
FILE: RELEASE.md
================================================
# Release Process
This document provides step-by-step instructions for releasing new versions of the golang-crossbuild project.
## Overview
This project follows the Golang versioning scheme, creating a GitHub Release for each specific Golang version. The release process ensures backward compatibility by maintaining separate branches for different Go versions.
We support the last two newer major versions, the same as the official Golang release [policy](https://go.dev/doc/devel/release#policy):
> Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release. We fix critical problems, including critical security problems, in supported releases as needed by issuing minor revisions (for example, Go 1.6.1, Go 1.6.2, and so on).
## 🤖 Primary Release Process: New Minor Go Version
This is the most common release scenario and it's fully automated using [updatecli](https://www.updatecli.io/docs/prologue/quick-start/).
The updatecli manifest can be found at:
* [.github/updatecli.d/bump-golang.yml](.github/updatecli.d/bump-golang.yml)
There are two GitHub workflows:
* [.github/workflows/bump-golang.yml](.github/workflows/bump-golang.yml) for updating the `main` branch.
* [.github/workflows/bump-golang-previous.yml](.github/workflows/bump-golang-previous.yml) for updating the previous active major Go version.
---
## 🚀 New Major Go Version
Follow these steps when a new major Go version is [released](https://go.dev/doc/devel/release).
### Prerequisites
- New Major Go version has been officially released or even for RCs.
- You have write access to the repository
- You're familiar with the current Go version in use
### Step-by-Step Instructions
#### 1. Prepare Version Branch
Create a branch for the previous major Go version to maintain backward compatibility.
**Example**: If upgrading from Go 1.25 to Go 1.26:
```bash
# Create branch for previous version (1.25)
git checkout main
git checkout -b 1.25
git push origin 1.25
```
#### 2. Update Core Version Files
Update the Go version in the main configuration files:
- **File**: `.go-version`
- Update to the new Go version (e.g., `1.26.0`)
- **File**: `go/Makefile.common` (line 5)
- Update the Docker tag to match the new version
#### 3. Run Version Bump Script
Execute the automated version bump script:
```bash
# Use Microsoft Golang release versioning normally 1.26.0-1
.github/updatecli.d/bump-go-version.sh "$(cat .go-version)-1"
```
#### 4. Update Documentation
- **File**: `README.md`
- Update all version references to the new Go version
#### 5. Update GitHub Workflows
- **File**: `.github/workflows/bump-golang.yml`
- Update `go-minor` value to new minor version (e.g., `1.26`)
- **File**: `.github/workflows/bump-golang-previous.yml`
- Update `go-minor` to previous minor version (e.g., `1.25`)
- Update `branch` value to previous minor version (e.g., `1.25`)
#### 6. Configure Backport Support
- **File**: `.mergify.yml`
- Add entry for new backport label: `backport-v1.25` (using previous version)
- **GitHub Labels**
- Create new label at: https://github.com/elastic/golang-crossbuild/labels
- Label name: `backport-v1.25` (using previous version)
#### 7. Commit and Create Pull Request in the `main` branch
```bash
git checkout main
git add -u
git commit -m "Update to Go 1.26.0" # Use actual version
```
Create a Pull Request with:
- **Title**: `Update to Go 1.26.0`
- **Description**: Brief summary of the Go version update
#### 8. Merge and Release
- Ensure all CI checks pass
- Merge the Pull Request
- The automation will automatically release the Docker images
> **⚠️ Important Note**: Due to changes in Debian package repositories, Docker images for previous Go versions may stop working over time.
### Example Scenario
```
Current State: Go 1.24 on main branch
New Release: Go 1.25
Actions:
1. Create branch "1.24" from main
2. Update main branch to Go 1.25
3. Follow steps 2-8 above
```
---
## 🔧 Specialized Release Processes
### NPCAP Release
For detailed instructions on releasing NPCAP versions, see the dedicated [NPCAP documentation](./NPCAP.md).
### FPM Release
> **📋 Status**: Not actively released (deprecated for several years)
> **Action**: To be documented when needed
### LLVM Apple Release
> **📋 Status**: Infrequent releases (approximately every 3 years)
> **Action**: To be documented when needed
---
## 🔄 Hotfix Process: Update Existing Released Version
Use this process for critical fixes to already-released versions.
### Prerequisites
- Existing release tag (e.g., `v1.25.1`)
- Critical fix that needs backporting
- Understanding of git branching and cherry-picking
### Step-by-Step Instructions
#### 1. Create Hotfix Branch
Create a maintenance branch for the specific version:
```bash
# Example for version 1.25.1
git checkout v1.25.1
git checkout -b 1.25.1.x # 'x' is literal, not a placeholder
git push upstream 1.25.1.x
```
#### 2. Apply Your Changes
1. Ensure your original PR is merged to main
2. Comment on the PR: `@mergifyio backport 1.25.1.x`
3. Mergify will automatically create a backport PR
4. Review and merge the backport PR when CI passes
#### 3. Release Process
- Merge the hotfix PR
- The automation will handle the release process
- Verify the new images are published
### Example Hotfix Scenario
```
Scenario: Critical security fix needed for Go 1.25.1
Steps:
1. git checkout v1.25.1
2. git checkout -b 1.25.1.x
3. git push upstream 1.25.1.x
4. Apply fix via backport or manual PR
5. Merge when CI passes
```
---
## 🍎 LLVM Apple Containers Release Process
> **📋 Status**: Infrequent releases (approximately every 3 years)
> **Use Case**: Cross-compilation for macOS targets from Linux environments
### When to Release LLVM Containers
- New Xcode/macOS SDK versions are available
- Security updates for LLVM toolchain
- Compatibility requirements for new macOS targets
- Critical bug fixes in the cross-compilation toolchain
### Prerequisites
- Access to Buildkite pipeline: https://buildkite.com/elastic/llvm-apple
- Understanding of LLVM/Clang toolchain versions
- Knowledge of macOS SDK compatibility requirements
### Step-by-Step Instructions
#### 1. Prepare for Release
- Verify the current LLVM/Clang version in the containers
- Check for any pending updates or security patches
- Review macOS SDK compatibility requirements
#### 2. Trigger Release Build
1. Navigate to the Buildkite pipeline: https://buildkite.com/elastic/llvm-apple
2. Click "New Build" button
3. Select branch: `main`
4. Set environment variable: `RELEASE=true`
5. Add build message: "Release LLVM Apple containers - [reason/version]"
6. Click "Create Build"
#### 3. Monitor Build Process
- Monitor the build progress in Buildkite console
- Expected build time: 4-5 hours (due to LLVM compilation)
- Watch for any compilation or packaging errors
- Verify all target architectures are built successfully
#### 4. Verify Release
After successful build completion:
```bash
# Check available container images
docker pull docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian11-arm64
docker inspect docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian11-arm64 | grep org.label-schema.build-date
```
Expected image tags:
- `docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian<version>(-arm64)?`
#### 5. Test Cross-Compilation
Verify the containers work correctly.
#### 6. Update Documentation
- Update any version references in README.md
- Document any breaking changes or new features
- Update compatibility matrix if applicable
### Container Image Locations
After successful release, images are available at:
- **Registry**: `docker.elastic.co/beats-dev/golang-crossbuild`
- **Tags**: `llvm-apple-debian<version>`, `llvm-apple-debian<version>-arm64`
- **Architectures**: `linux/amd64`, `linux/arm64`
### Supported Cross-Compilation Targets
- **macOS**: `darwin/amd64`, `darwin/arm64`
- **iOS**: `ios/amd64`, `ios/arm64` (if configured)
### Troubleshooting LLVM Releases
#### Common Issues
1. **Build Timeouts**: LLVM compilation is resource-intensive
- **Solution**: Retry build or check Buildkite agent resources
2. **SDK Download Failures**: Xcode SDK downloads may fail
- **Solution**: Verify SDK availability and download URLs
3. **Cross-compilation Errors**: Target-specific compilation issues
- **Solution**: Test with sample projects before full release
4. **Container Registry Issues**: Push failures to docker.elastic.co
- **Solution**: Check registry credentials and network connectivity
---
## 📚 Quick Reference
### File Locations
| Component | File Path |
|-----------|-----------|
| Go Version | `.go-version` |
| Docker Tag | `go/Makefile.common` (line 5) |
| Main Workflow | `.github/workflows/bump-golang.yml` |
| Previous Workflow | `.github/workflows/bump-golang-previous.yml` |
| Mergify Config | `.mergify.yml` |
| Version Bump Script | `.github/updatecli.d/bump-go-release-version.sh` |
### Branch Naming Convention
- **Main development**: `main`
- **Version branches**: `1.23`, `1.24` (major.minor format)
- **Hotfix branches**: `1.25.1.x` (major.minor.patch.x format)
### Automation
- **Docker Images**: Released automatically on PR merge
- **Backports**: Available via Mergify (`@mergifyio backport <branch>`)
- **CI/CD**: All releases go through automated testing
---
## ❓ Troubleshooting
### Common Issues
1. **CI Failures**: Ensure all version references are updated consistently
2. **Docker Build Errors**: Check Debian package repository availability
3. **Backport Conflicts**: Resolve manually and create new PR
4. **Missing Labels**: Create GitHub labels before using backport commands
### Support
- Check existing GitHub issues and PRs for similar problems
- Review CI logs for specific error messages
- Consult team members for complex release scenarios
================================================
FILE: catalog-info.yaml
================================================
# Declare a Backstage Component that represents your application.
---
# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: golang-crossbuild
spec:
type: tool
owner: group:ingest-fp
system: platform-ingest
lifecycle: production
---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: buildkite-pipeline-golang-crossbuild
description: 'Pipeline for the golang-crossbuild project'
links:
- title: Pipeline
url: https://buildkite.com/elastic/golang-crossbuild
spec:
type: buildkite-pipeline
owner: group:ingest-fp
system: buildkite
implementation:
apiVersion: buildkite.elastic.dev/v1
kind: Pipeline
metadata:
name: golang-crossbuild
description: 'Pipeline for the golang-crossbuild project'
spec:
branch_configuration: "main 1.*" # temporarily disable to build PRs from forks
pipeline_file: ".buildkite/pipeline.yml"
maximum_timeout_in_minutes: 360 # LLVM apple pipelines is taking at least 4h to run
provider_settings:
build_tags: true
publish_commit_status: true
build_pull_request_forks: false
build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot
filter_enabled: true
filter_condition: >-
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
repository: elastic/golang-crossbuild
cancel_intermediate_builds: true
cancel_intermediate_builds_branch_filter: '!main !1.*'
skip_intermediate_builds: true
skip_intermediate_builds_branch_filter: '!main !1.*'
env:
ELASTIC_PR_COMMENTS_ENABLED: 'true'
teams:
ingest-fp:
access_level: MANAGE_BUILD_AND_READ
observablt-robots:
access_level: BUILD_AND_READ
everyone:
access_level: READ_ONLY
schedules:
Daily:
branch: main
cronline: "0 12 * * * America/New_York"
message: "Builds once per day"
---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: buildkite-pipeline-llvm-apple-version
description: "Pipeline for LLVM Apple version"
links:
- title: Pipeline
url: https://buildkite.com/elastic/llvm-apple
spec:
type: buildkite-pipeline
owner: group:ingest-fp
system: buildkite
implementation:
apiVersion: buildkite.elastic.dev/v1
kind: Pipeline
metadata:
name: llvm-apple
description: "Pipeline for LLVM Apple version"
spec:
branch_configuration: "main 1.*" # temporarily disable to build PRs from forks
pipeline_file: ".buildkite/llvm-apple-pipeline.yml"
maximum_timeout_in_minutes: 360 # cmake is taking at least 4h to run
provider_settings:
build_tags: true
publish_commit_status: true
build_pull_request_forks: false
build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot
filter_enabled: true
filter_condition: >-
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
repository: elastic/golang-crossbuild
cancel_intermediate_builds: true
cancel_intermediate_builds_branch_filter: '!main'
skip_intermediate_builds: true
skip_intermediate_builds_branch_filter: '!main'
env:
ELASTIC_PR_COMMENTS_ENABLED: 'false'
teams:
ingest-fp:
access_level: MANAGE_BUILD_AND_READ
observablt-robots:
access_level: BUILD_AND_READ
everyone:
access_level: READ_ONLY
---
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: buildkite-pipeline-fpm
description: "Pipeline for FPM (packaging made simple)"
links:
- title: Pipeline
url: https://buildkite.com/elastic/fpm
spec:
type: buildkite-pipeline
owner: group:ingest-fp
system: buildkite
implementation:
apiVersion: buildkite.elastic.dev/v1
kind: Pipeline
metadata:
name: fpm
description: "Pipeline for FPM (packaging made simple)"
spec:
branch_configuration: "main 1.*" # temporarily disable to build PRs from forks
pipeline_file: ".buildkite/fpm-pipeline.yml"
maximum_timeout_in_minutes: 360 # cmake is taking at least 4h to run
provider_settings:
build_tags: true
publish_commit_status: true
build_pull_request_forks: false
build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot
filter_enabled: true
filter_condition: >-
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
repository: elastic/golang-crossbuild
cancel_intermediate_builds: true
cancel_intermediate_builds_branch_filter: '!main'
skip_intermediate_builds: true
skip_intermediate_builds_branch_filter: '!main'
env:
ELASTIC_PR_COMMENTS_ENABLED: 'false'
teams:
ingest-fp:
access_level: MANAGE_BUILD_AND_READ
observablt-robots:
access_level: BUILD_AND_READ
everyone:
access_level: READ_ONLY
================================================
FILE: fpm/.dockerignore
================================================
Makefile
================================================
FILE: fpm/Dockerfile.tmpl
================================================
FROM debian:bullseye
LABEL maintainer="Elastic Beats Team"
RUN \
apt-get update && \
apt-get install -y --no-install-recommends \
autoconf build-essential libffi-dev ruby-dev rpm zip dos2unix libgmp3-dev \
curl make gcc \
&& rm -rf /var/lib/apt/lists/*
ARG SUEXEC_VERSION=0.2
ARG SUEXEC_DOWNLOAD_URL=https://github.com/ncopa/su-exec/archive/v${SUEXEC_VERSION}.tar.gz
ARG SUEXEC_DOWNLOAD_SHA256=ec4acbd8cde6ceeb2be67eda1f46c709758af6db35cacbcde41baac349855e25
RUN \
curl -fsSL "$SUEXEC_DOWNLOAD_URL" -o suexec.tar.gz \
&& echo "$SUEXEC_DOWNLOAD_SHA256 suexec.tar.gz" | sha256sum -c - \
&& mkdir /suexec \
&& tar -C /suexec --strip-components=1 -xzf suexec.tar.gz \
&& make -C /suexec \
&& mv /suexec/su-exec /usr/bin/ \
&& rm -rf /suexec suexec.tar.gz
ARG FPM_VERSION
RUN gem install fpm -v "$FPM_VERSION"
COPY rootfs /
ENTRYPOINT ["/entrypoint.sh"]
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: fpm/Makefile
================================================
include ../Makefile.common
NAME := fpm
VERSION := 1.13.1
build:
@echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)"
@go run ../template.go -t Dockerfile.tmpl -o Dockerfile
@docker run --privileged --rm tonistiigi/binfmt --install all
@docker buildx ls
@echo 'Create builder'
@docker buildx create --name "multiarchcontext"
@docker buildx use "multiarchcontext"
@docker buildx inspect --bootstrap
@echo 'Build Docker image'
@docker buildx build --progress=plain --platform "linux/amd64,linux/arm64" -t "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)" \
--build-arg FPM_VERSION=$(VERSION) \
--build-arg IMAGE="$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \
--build-arg VCS_REF="$(VCS_REF)" \
--build-arg VCS_URL="$(VCS_URL)" \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
--push .
.PHONY: build
================================================
FILE: fpm/rootfs/entrypoint.sh
================================================
#!/usr/bin/env sh
if [ -z ${EXEC_UID+x} ] || [ -z ${EXEC_GID+x} ]; then
exec "$@"
fi
groupadd -f -g "$EXEC_GID" fpm
useradd -N -m -c 'FPM User' -u "$EXEC_UID" -g "$EXEC_GID" fpm
su-exec fpm "$@"
================================================
FILE: go/Makefile
================================================
include ./Makefile.debian9
TAG_EXTENSION := ""
================================================
FILE: go/Makefile.common
================================================
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
include $(SELF_DIR)/../Makefile.common
NAME := golang-crossbuild
VERSION := 1.26.2
DEBIAN_VERSION ?= 9
SUFFIX := -$(shell basename $(CURDIR))
TAG_EXTENSION ?=
FIPS ?=
ifeq "${FIPS}" "true"
ifeq ($(findstring -fips,$(TAG_EXTENSION)),)
TAG_EXTENSION:=$(TAG_EXTENSION)-fips
endif
endif
export DEBIAN_VERSION TAG_EXTENSION NPCAP_FILE
DOCKER_CMD := docker build --progress=plain
build: copy-npcap copy-sdks
@echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)"
@go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile
@$(DOCKER_CMD) -t "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \
--build-arg REPOSITORY=$(REPOSITORY) \
--build-arg VERSION=$(VERSION) \
--build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) \
--build-arg TAG_EXTENSION=$(TAG_EXTENSION) \
--build-arg IMAGE="$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \
--build-arg VCS_REF="$(VCS_REF)" \
--build-arg VCS_URL="$(VCS_URL)" \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
.
build-arm: copy-sdks
@echo $(SELF_DIR)
@echo ">> Building $(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)"
@go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile
@docker build -t "$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \
--progress=plain \
--build-arg REPOSITORY=$(REPOSITORY) \
--build-arg VERSION=$(VERSION) \
--build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) \
--build-arg TAG_EXTENSION=$(TAG_EXTENSION) \
--build-arg IMAGE="$(REPOSITORY)/$(NAME):$(VERSION)$(SUFFIX)$(TAG_EXTENSION)" \
--build-arg VCS_REF="$(VCS_REF)" \
--build-arg VCS_URL="$(VCS_URL)" \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
.
.PHONY: build build-arm
================================================
FILE: go/Makefile.debian10
================================================
IMAGES := base main darwin armhf npcap
ARM_IMAGES := base-arm darwin-arm64
DEBIAN_VERSION := 10
TAG_EXTENSION := -debian10
export DEBIAN_VERSION TAG_EXTENSION
build:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)
build-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)
# Requires login at https://docker.elastic.co:7000/.
push:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)
push-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)
.PHONY: build build-arm push push-arm
================================================
FILE: go/Makefile.debian11
================================================
IMAGES := base main darwin armhf npcap
ARM_IMAGES := base-arm darwin-arm64
DEBIAN_VERSION := 11
TAG_EXTENSION := -debian11
export DEBIAN_VERSION TAG_EXTENSION
build:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)
build-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)
# Requires login at https://docker.elastic.co:7000/.
push:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)
push-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)
.PHONY: build build-arm push push-arm
================================================
FILE: go/Makefile.debian12
================================================
IMAGES := base main darwin armhf armel mips ppc s390x npcap
ARM_IMAGES := base-arm darwin-arm64 windows-arm64
DEBIAN_VERSION := 12
TAG_EXTENSION := -debian12
export DEBIAN_VERSION TAG_EXTENSION
build:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)
build-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)
# Requires login at https://docker.elastic.co:7000/.
push:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)
push-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)
.PHONY: build build-arm push push-arm
================================================
FILE: go/Makefile.debian7
================================================
IMAGES := base main
DEBIAN_VERSION := 7
TAG_EXTENSION := -debian7
export DEBIAN_VERSION TAG_EXTENSION
build:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)
# Requires login at https://docker.elastic.co:7000/.
push:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)
.PHONY: build push
================================================
FILE: go/Makefile.debian8
================================================
IMAGES := base main darwin npcap
ARM_IMAGES := base-arm
DEBIAN_VERSION := 8
TAG_EXTENSION := -debian8
export DEBIAN_VERSION TAG_EXTENSION
build:
export |grep TAG_EXTENSION
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)
build-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)
# Requires login at https://docker.elastic.co:7000/.
push:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)
push-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)
.PHONY: build build-arm push push-arm
================================================
FILE: go/Makefile.debian9
================================================
IMAGES := base main darwin armhf npcap
ARM_IMAGES := base-arm
DEBIAN_VERSION := 9
TAG_EXTENSION := -debian9
export DEBIAN_VERSION TAG_EXTENSION
build:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) build || exit 1;)
build-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) build-arm || exit 1;)
# Requires login at https://docker.elastic.co:7000/.
push:
@$(foreach var,$(IMAGES),$(MAKE) -C $(var) push || exit 1;)
push-arm:
@$(foreach var,$(ARM_IMAGES),$(MAKE) -C $(var) push-arm || exit 1;)
.PHONY: build build-arm push push-arm
================================================
FILE: go/arm/.dockerignore
================================================
Makefile
================================================
FILE: go/arm/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM --platform=linux/amd64 ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} AS stage-amd64
RUN dpkg --add-architecture arm64 \
&& apt update -y --no-install-recommends \
&& apt upgrade -y --no-install-recommends \
&& apt full-upgrade -y --no-install-recommends \
&& apt install -qq -y --no-install-recommends \
crossbuild-essential-arm64 \
linux-libc-dev-arm64-cross
RUN apt install -qq -y \
libc-dev:arm64 \
libpopt-dev:arm64 \
linux-libc-dev:arm64
{{- if eq .DEBIAN_VERSION "9"}}
# librpm-dev
RUN apt install -y \
librpm-dev:arm64 \
librpm3:arm64 \
librpmio3:arm64 \
librpmbuild3:arm64 \
librpmsign3:arm64 \
libxml2-dev:arm64 \
libsqlite3-dev:arm64 \
libnss3:arm64 \
libsqlite3-0:arm64 \
libxml2:arm64 \
libsqlite3-0:arm64
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:arm64 libsystemd0:arm64 liblz4-1:arm64
{{- end }}
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
RUN apt install -y \
librpm-dev:arm64
RUN apt install -y \
libsystemd-dev:arm64
{{- end }}
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM --platform=linux/arm64 ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} AS stage-arm64
RUN dpkg --add-architecture arm64 \
&& apt update -y --no-install-recommends \
&& apt upgrade -y --no-install-recommends \
&& apt full-upgrade -y --no-install-recommends \
&& apt install -qq -y --no-install-recommends \
build-essential \
libc-dev \
libpopt-dev \
linux-libc-dev
{{- if eq .DEBIAN_VERSION "9"}}
# librpm-dev
RUN apt install -y \
librpm-dev \
librpm3 \
librpmio3 \
librpmbuild3 \
librpmsign3 \
libxml2-dev \
libsqlite3-dev \
libnss3 \
libsqlite3-0 \
libxml2 \
libsqlite3-0
# libsystemd-dev
RUN apt install -y \
libsystemd-dev libsystemd0 liblz4-1
{{- end }}
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
# librpm-dev
RUN apt install -y \
librpm-dev
RUN apt install -y \
libsystemd-dev
{{- end }}
# Declare TARGETARCH to make it available
ARG TARGETARCH=amd64
# Select final stage based on TARGETARCH ARG
FROM stage-${TARGETARCH} AS final
RUN rm -rf /var/lib/apt/lists/*
COPY rootfs /
# Basic test
RUN cd / \
&& aarch64-linux-gnu-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& file helloWorld | cut -d "," -f 2 | grep -c 'ARM aarch64'\
&& rm helloWorld.c helloWorld
RUN cd /libpcap/libpcap-1.8.1 \
&& CC=aarch64-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=aarch64-unknown-linux-gnu --with-pcap=linux \
&& make
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/arm/Makefile
================================================
include ../Makefile.common
ifeq ($(DOCKER_MULTIARCH),1)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
ifeq ($(BUILDX)$(DEBIAN_VERSION),19)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
================================================
FILE: go/arm/rootfs/compilers.yaml
================================================
---
linux:
arm64:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
================================================
FILE: go/arm/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/armel/.dockerignore
================================================
Makefile
================================================
FILE: go/armel/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}
RUN dpkg --add-architecture armel \
&& apt update -y --no-install-recommends \
&& apt upgrade -y --no-install-recommends \
&& apt full-upgrade -y --no-install-recommends \
&& apt install -qq -y --no-install-recommends \
crossbuild-essential-armel \
linux-libc-dev-armel-cross
RUN apt install -qq -y \
libc-dev:armel \
libpopt-dev:armel \
linux-libc-dev:armel
{{- if eq .DEBIAN_VERSION "9"}}
# librpm-dev
RUN apt install -y \
librpm-dev:armel \
librpm3:armel \
librpmio3:armel \
librpmbuild3:armel \
librpmsign3:armel \
libxml2-dev:armel \
libsqlite3-dev:armel \
libnss3:armel \
libsqlite3-0:armel \
libxml2:armel \
libsqlite3-0:armel
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:armel libsystemd0:armel liblz4-1:armel
{{- end }}
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
# librpm-dev
RUN apt install -y \
librpm-dev:armel
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:armel
{{- end }}
RUN rm -rf /var/lib/apt/lists/*
COPY rootfs /
# Basic test
RUN cd / \
&& arm-linux-gnueabi-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& file helloWorld | cut -d "," -f 3 | grep -c 'EABI'\
&& rm helloWorld.c helloWorld
RUN cd /libpcap/libpcap-1.8.1 \
&& CC=arm-linux-gnueabi-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=arm-linux-gnueabi --with-pcap=linux \
&& make
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/armel/Makefile
================================================
include ../Makefile.common
================================================
FILE: go/armel/rootfs/compilers.yaml
================================================
---
linux:
armv6:
# Using debian armel for ARMv6.
# This is the same as ARMv5 so it will use softfp instead of hardfp.
CC: arm-linux-gnueabi-gcc
CXX: arm-linux-gnueabi-g++
armv5:
CC: arm-linux-gnueabi-gcc
CXX: arm-linux-gnueabi-g++
================================================
FILE: go/armel/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/armhf/.dockerignore
================================================
Makefile
================================================
FILE: go/armhf/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}
RUN dpkg --add-architecture armhf \
&& apt update -y --no-install-recommends \
&& apt upgrade -y --no-install-recommends \
&& apt full-upgrade -y --no-install-recommends \
&& apt install -qq -y --no-install-recommends \
crossbuild-essential-armhf \
linux-libc-dev-armhf-cross
RUN apt install -qq -y \
libc-dev:armhf \
libpopt-dev:armhf \
linux-libc-dev:armhf
{{- if eq .DEBIAN_VERSION "9"}}
# librpm-dev
RUN apt install -y \
librpm-dev:armhf \
librpm3:armhf \
librpmio3:armhf \
librpmbuild3:armhf \
librpmsign3:armhf \
libxml2-dev:armhf \
libsqlite3-dev:armhf \
libnss3:armhf \
libsqlite3-0:armhf \
libxml2:armhf \
libsqlite3-0:armhf
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:armhf libsystemd0:armhf liblz4-1:armhf
{{- end }}
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
# librpm-dev
RUN apt install -y \
librpm-dev:armhf
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:armhf
{{- end }}
RUN rm -rf /var/lib/apt/lists/*
COPY rootfs /
# Basic test
RUN cd / \
&& arm-linux-gnueabihf-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& file helloWorld | cut -d "," -f 5 | grep -c 'armhf.so'\
&& rm helloWorld.c helloWorld
RUN cd /libpcap/libpcap-1.8.1 \
&& CC=arm-linux-gnueabihf-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=arm-linux-gnueabihf --with-pcap=linux \
&& make
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/armhf/Makefile
================================================
include ../Makefile.common
================================================
FILE: go/armhf/rootfs/compilers.yaml
================================================
---
linux:
armv7:
CC: arm-linux-gnueabihf-gcc
CXX: arm-linux-gnueabihf-g++
================================================
FILE: go/armhf/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/base/.dockerignore
================================================
Makefile
================================================
FILE: go/base/Dockerfile.tmpl
================================================
ARG DEBIAN_VERSION=9
FROM debian:${DEBIAN_VERSION}
ARG DEBIAN_VERSION
# Replace sources.list in order to use archive.debian.org.
COPY sources-debian${DEBIAN_VERSION}.list /etc/apt/sources.list
RUN apt-get -o Acquire::Check-Valid-Until=false update -y --no-install-recommends --allow-unauthenticated \
&& apt-get upgrade -y --no-install-recommends --allow-unauthenticated \
&& apt-get dist-upgrade -y --no-install-recommends --allow-unauthenticated \
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
build-essential \
ca-certificates \
curl \
git \
gnupg \
make \
file \
flex \
bison \
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
binutils-multiarch \
binutils-multiarch-dev \
python3-venv \
python3-pip \
python3 \
{{- end }}
&& rm -rf /var/lib/apt/lists/*
{{- if eq .DEBIAN_VERSION "10"}}
RUN ln -s /usr/bin/pip3 /usr/bin/pip
{{- end }}
ARG VERSION
{{- if eq .FIPS "true"}}
ARG SECURITY_VERSION=-1
ARG GOLANG_DOWNLOAD_URL=https://aka.ms/golang/release/latest/go$VERSION$SECURITY_VERSION.linux-amd64.tar.gz
# Use a different arg name for microsoft/go sha so it can be handled seperately from the regular golang sha
ARG MSFT_DOWNLOAD_SHA256=68bcd46d095165b37f4773450a8239ae5aa8d7e5be371eb69aea0510526ced5a
ARG DOWNLOAD_SHA256=$MSFT_DOWNLOAD_SHA256
{{- else}}
ARG GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$VERSION.linux-amd64.tar.gz
ARG GOLANG_DOWNLOAD_SHA256=990e6b4bbba816dc3ee129eaeaf4b42f17c2800b88a2166c265ac1a200262282
ARG DOWNLOAD_SHA256=$GOLANG_DOWNLOAD_SHA256
{{- end }}
RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& echo "$DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
&& rm -rf /usr/local/go \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz
ENV GOPATH=/go
ENV PATH=$PATH:/usr/local/go/bin
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
WORKDIR $GOPATH
# Validate the Go installation
RUN go version \
&& go version | grep "go${VERSION}" || (echo "Go version mismatch: expected to contain go${VERSION}" && exit 1)
COPY rootfs /
# show the GLIBC version
RUN ldd --version
WORKDIR /
RUN mkdir -p /root/.config/go/telemetry && echo "off 2024-08-23" > /root/.config/go/telemetry/mode
ENV GOTOOLCHAIN=local
RUN go mod init github.com/elastic/golang-crossbuild-$VERSION \
&& go get . \
&& go env \
&& echo "toolcompile=$(go tool compile -V)" \
&& CGO_ENABLED=0 GOARCH=amd64 go build -o /crossbuild /entrypoint.go \
&& rm -rf /go/* /root/.cache/* /entrypoint.go
COPY sdks/libpcap-1.8.1.tar.gz .
RUN mkdir /libpcap \
&& tar -xzf libpcap-1.8.1.tar.gz -C /libpcap \
&& rm libpcap-1.8.1.tar.gz
{{- if eq .FIPS "true"}}
ENV GOEXPERIMENT=systemcrypto
ENV CGO_ENABLED=1
ENV MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0
{{- end}}
ENV GOLANG_CROSSBUILD=1
VOLUME /app
WORKDIR /app
ENTRYPOINT ["/crossbuild"]
================================================
FILE: go/base/Makefile
================================================
include ../Makefile.common
ifeq ($(DOCKER_MULTIARCH),1)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
ifeq ($(BUILDX)$(DEBIAN_VERSION),19)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
================================================
FILE: go/base/rootfs/entrypoint.go
================================================
// +build linux
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"sort"
"strings"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
var rootCmd = &cobra.Command{
Use: "crossbuild",
Short: "crossbuild is simple tool for cross-compiling Go binaries",
Long: `crossbuild is a containerized tool for cross-compiling Go binaries
by mounting the project inside of a container equipped with cross-compilers.
The root of your project's repo should be mounted at the appropriate location
on the GOPATH which is set to /go.
While executing the build command the following variables will be added to the
environment: GOOS, GOARCH, GOARM, GOTOOLCHAIN=local, PLATFORM_ID, CC, and CXX.
`,
RunE: doBuild,
SilenceUsage: true,
}
func init() {
rootCmd.PersistentFlags().StringVarP(&buildCommand, "build-cmd", "c",
"make build", "Build command to execute.")
rootCmd.PersistentFlags().StringSliceVarP(&platforms, "platforms", "p", nil,
"Target platform for the binary in GOOS/GOARCH format (e.g. windows/amd64).")
rootCmd.MarkPersistentFlagRequired("platforms")
}
func main() {
log.SetFlags(0)
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}
var (
buildCommand string
platforms []string
)
func doBuild(_ *cobra.Command, _ []string) error {
for _, p := range platforms {
env, err := buildEnvironment(p)
if err != nil {
return fmt.Errorf("failed constructing the build environment for %v: %v", p, err)
}
if err = execBuildCommand(env); err != nil {
return fmt.Errorf("failed building for %v: %v", p, err)
}
}
return nil
}
func isDirEmpty(name string) (bool, error) {
f, err := os.Open(name)
if err != nil {
return false, err
}
defer f.Close()
_, err = f.Readdirnames(1)
if err == io.EOF {
return true, nil
}
return false, err
}
func buildEnvironment(platform string) (map[string]string, error) {
parts := strings.SplitN(platform, "/", 2)
if len(parts) != 2 {
return nil, fmt.Errorf("invalid platform %v", platform)
}
platformID := strings.Join(parts, "-")
goos := parts[0]
arch := parts[1]
goarch := arch
goarm := ""
if strings.HasPrefix(arch, "armv") {
goarch = "arm"
goarm = strings.TrimPrefix(arch, "armv")
}
env := map[string]string{
"GOOS": goos,
"GOARCH": goarch,
"GOARM": goarm,
"GOTOOLCHAIN": "local", // Disable automatic downloads of toolchains for reproducible builds.
"PLATFORM_ID": platformID,
}
if err := loadCompilerSettings(goos, arch, env); err != nil {
return nil, fmt.Errorf("failed while loading compiler settings: %v", err)
}
return env, nil
}
type Compilers struct {
GOOS map[string]struct {
Arch map[string]struct {
Env map[string]string `yaml:",inline"`
} `yaml:",inline"`
} `yaml:",inline"`
}
func loadCompilerSettings(goos, arch string, env map[string]string) error {
data, err := ioutil.ReadFile("/compilers.yaml")
if err != nil {
if os.IsNotExist(err) {
return nil
}
return fmt.Errorf("failed to read /compilers.yaml: %v", err)
}
var compilers Compilers
if err = yaml.Unmarshal(data, &compilers); err != nil {
return fmt.Errorf("failed to parse /compilers.yaml: %v", err)
}
arches, found := compilers.GOOS[goos]
if !found {
return fmt.Errorf("%v is not supported by this image", goos)
}
settings, found := arches.Arch[arch]
if !found {
return fmt.Errorf("%v/%v is not supported by this image", goos, arch)
}
for k, v := range settings.Env {
env[k] = v
}
return nil
}
func execBuildCommand(env map[string]string) error {
cmd := exec.Command("sh", "-c", buildCommand)
cmd.Env = os.Environ()
logEnv := make([]string, 0, len(env))
for k, v := range env {
kv := k + "=" + v
cmd.Env = append(cmd.Env, kv)
logEnv = append(logEnv, kv)
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
var b strings.Builder
sort.Strings(logEnv)
fmt.Fprintf(&b, ">> Building using: cmd='%v', env=[%v]", buildCommand, strings.Join(logEnv, ", "))
log.Println(b.String())
return cmd.Run()
}
================================================
FILE: go/base/sources-debian10.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb http://archive.debian.org/debian buster main
deb http://archive.debian.org/debian-security buster/updates main
================================================
FILE: go/base/sources-debian11.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb http://deb.debian.org/debian bullseye main
deb http://deb.debian.org/debian bullseye-updates main
deb http://deb.debian.org/debian-security/ bullseye-security main
================================================
FILE: go/base/sources-debian12.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb http://deb.debian.org/debian bookworm main
deb http://deb.debian.org/debian-security/ bookworm-security main
================================================
FILE: go/base/sources-debian7.list
================================================
# see https://wiki.debian.org/CrossToolchains
# https://bugs.launchpad.net/torios/+bug/1835529
deb http://archive.debian.org/debian wheezy main
deb http://archive.debian.org/debian-security wheezy/updates main
================================================
FILE: go/base/sources-debian8.list
================================================
# see https://wiki.debian.org/CrossToolchains
# https://bugs.launchpad.net/torios/+bug/1835529
deb http://archive.debian.org/debian jessie main
deb http://archive.debian.org/debian-security jessie/updates main
================================================
FILE: go/base/sources-debian9.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb http://archive.debian.org/debian stretch main
deb http://archive.debian.org/debian-security stretch/updates main
================================================
FILE: go/base-arm/Dockerfile.tmpl
================================================
ARG DEBIAN_VERSION=9
FROM arm64v8/debian:${DEBIAN_VERSION}
ARG DEBIAN_VERSION
# Replace sources.list in order to use archive.debian.org.
COPY sources-debian${DEBIAN_VERSION}.list /etc/apt/sources.list
RUN \
apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get dist-upgrade -y \
&& apt-get install -qq -y --no-install-recommends --allow-unauthenticated \
build-essential \
ca-certificates \
curl \
git \
gnupg \
make \
file \
flex \
bison \
librpm-dev \
libc-dev \
libpopt-dev \
linux-libc-dev \
libxml2-dev \
libxml2 \
libicu-dev \
icu-devtools \
libsystemd-dev \
{{- if eq .DEBIAN_VERSION "8" }}
libicu52 \
librpm3 \
librpmio3 \
librpmbuild3 \
librpmsign1 \
{{- else if eq .DEBIAN_VERSION "9" }}
libicu57 \
librpm3 \
librpmio3 \
librpmbuild3 \
librpmsign3 \
{{- else if eq .DEBIAN_VERSION "10" }}
libicu63 \
librpm8 \
librpmio8 \
librpmbuild8 \
librpmsign8 \
{{- else if eq .DEBIAN_VERSION "11" }}
libicu67 \
librpm9 \
librpmio9 \
librpmbuild9 \
librpmsign9 \
{{- else }}
libicu72 \
librpm9 \
librpmio9 \
librpmbuild9 \
librpmsign9 \
{{- end }}
libsqlite3-dev \
libnss3 \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*
ARG VERSION
{{- if eq .FIPS "true"}}
ARG SECURITY_VERSION=-1
ARG GOLANG_DOWNLOAD_URL=https://aka.ms/golang/release/latest/go$VERSION$SECURITY_VERSION.linux-arm64.tar.gz
# Use a different arg name for microsoft/go sha so it can be handled seperately from the regular golang sha
ARG MSFT_DOWNLOAD_SHA256=0274f18451d73bf234798b1d1212e60b59ed1cd86d1b982701df3df76c563571
ARG DOWNLOAD_SHA256=$MSFT_DOWNLOAD_SHA256
{{- else}}
ARG GOLANG_DOWNLOAD_URL=https://golang.org/dl/go$VERSION.linux-arm64.tar.gz
ARG GOLANG_DOWNLOAD_SHA256=c958a1fe1b361391db163a485e21f5f228142d6f8b584f6bef89b26f66dc5b23
ARG DOWNLOAD_SHA256=$GOLANG_DOWNLOAD_SHA256
{{- end}}
RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
&& echo "$DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \
&& rm -rf /usr/local/go \
&& tar -C /usr/local -xzf golang.tar.gz \
&& rm golang.tar.gz
ENV GOPATH=/go
ENV PATH=$PATH:/usr/local/go/bin
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
WORKDIR $GOPATH
# Validate the Go installation
RUN go version \
&& go version | grep "go${VERSION}" || (echo "Go version mismatch: expected to contain go${VERSION}" && exit 1)
COPY rootfs /
# show the GLIBC version
RUN ldd --version
WORKDIR /
RUN mkdir -p /root/.config/go/telemetry && echo "off 2024-08-23" > /root/.config/go/telemetry/mode
ENV GOTOOLCHAIN=local
RUN go mod init github.com/elastic/golang-crossbuild-$VERSION-arm \
&& go get . \
&& go env \
&& echo "toolcompile=$(go tool compile -V)" \
&& CGO_ENABLED=0 GOARCH=arm64 go build -o /crossbuild /entrypoint.go \
&& rm -rf /go/* /root/.cache/* /entrypoint.go
COPY sdks/libpcap-1.8.1.tar.gz .
RUN mkdir /libpcap \
&& tar -xzf libpcap-1.8.1.tar.gz -C /libpcap \
&& cd /libpcap/libpcap-1.8.1 \
&& ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=aarch64-unknown-linux-gnu --with-pcap=linux \
&& make
{{- if eq .FIPS "true"}}
ENV GOEXPERIMENT=systemcrypto
ENV CGO_ENABLED=1
ENV MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0
{{- end}}
ENV GOLANG_CROSSBUILD=1
VOLUME /app
WORKDIR /app
ENTRYPOINT ["/crossbuild"]
================================================
FILE: go/base-arm/Makefile
================================================
include ../Makefile.common
================================================
FILE: go/base-arm/rootfs/entrypoint.go
================================================
// +build linux
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
"sort"
"strings"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)
var rootCmd = &cobra.Command{
Use: "crossbuild",
Short: "crossbuild is simple tool for cross-compiling Go binaries",
Long: `crossbuild is a containerized tool for cross-compiling Go binaries
by mounting the project inside of a container equipped with cross-compilers.
The root of your project's repo should be mounted at the appropriate location
on the GOPATH which is set to /go.
While executing the build command the following variables will be added to the
environment: GOOS, GOARCH, GOARM, GOTOOLCHAIN=local, PLATFORM_ID, CC, and CXX.
`,
RunE: doBuild,
SilenceUsage: true,
}
func init() {
rootCmd.PersistentFlags().StringVarP(&buildCommand, "build-cmd", "c",
"make build", "Build command to execute.")
rootCmd.PersistentFlags().StringSliceVarP(&platforms, "platforms", "p", nil,
"Target platform for the binary in GOOS/GOARCH format (e.g. windows/amd64).")
rootCmd.MarkPersistentFlagRequired("platforms")
}
func main() {
log.SetFlags(0)
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}
var (
buildCommand string
platforms []string
)
func doBuild(_ *cobra.Command, _ []string) error {
for _, p := range platforms {
env, err := buildEnvironment(p)
if err != nil {
return fmt.Errorf("failed constructing the build environment for %v: %v", p, err)
}
if err = execBuildCommand(env); err != nil {
return fmt.Errorf("failed building for %v: %v", p, err)
}
}
return nil
}
func isDirEmpty(name string) (bool, error) {
f, err := os.Open(name)
if err != nil {
return false, err
}
defer f.Close()
_, err = f.Readdirnames(1)
if err == io.EOF {
return true, nil
}
return false, err
}
func buildEnvironment(platform string) (map[string]string, error) {
parts := strings.SplitN(platform, "/", 2)
if len(parts) != 2 {
return nil, fmt.Errorf("invalid platform %v", platform)
}
platformID := strings.Join(parts, "-")
goos := parts[0]
arch := parts[1]
goarch := arch
goarm := ""
if strings.HasPrefix(arch, "armv") {
goarch = "arm"
goarm = strings.TrimPrefix(arch, "armv")
}
env := map[string]string{
"GOOS": goos,
"GOARCH": goarch,
"GOARM": goarm,
"GOTOOLCHAIN": "local", // Disable automatic downloads of toolchains for reproducible builds.
"PLATFORM_ID": platformID,
}
if err := loadCompilerSettings(goos, arch, env); err != nil {
return nil, fmt.Errorf("failed while loading compiler settings: %v", err)
}
return env, nil
}
type Compilers struct {
GOOS map[string]struct {
Arch map[string]struct {
Env map[string]string `yaml:",inline"`
} `yaml:",inline"`
} `yaml:",inline"`
}
func loadCompilerSettings(goos, arch string, env map[string]string) error {
data, err := ioutil.ReadFile("/compilers.yaml")
if err != nil {
if os.IsNotExist(err) {
return nil
}
return fmt.Errorf("failed to read /compilers.yaml: %v", err)
}
var compilers Compilers
if err = yaml.Unmarshal(data, &compilers); err != nil {
return fmt.Errorf("failed to parse /compilers.yaml: %v", err)
}
arches, found := compilers.GOOS[goos]
if !found {
return fmt.Errorf("%v is not supported by this image", goos)
}
settings, found := arches.Arch[arch]
if !found {
return fmt.Errorf("%v/%v is not supported by this image", goos, arch)
}
for k, v := range settings.Env {
env[k] = v
}
return nil
}
func execBuildCommand(env map[string]string) error {
cmd := exec.Command("sh", "-c", buildCommand)
cmd.Env = os.Environ()
logEnv := make([]string, 0, len(env))
for k, v := range env {
kv := k + "=" + v
cmd.Env = append(cmd.Env, kv)
logEnv = append(logEnv, kv)
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
var b strings.Builder
sort.Strings(logEnv)
fmt.Fprintf(&b, ">> Building using: cmd='%v', env=[%v]", buildCommand, strings.Join(logEnv, ", "))
log.Println(b.String())
return cmd.Run()
}
================================================
FILE: go/base-arm/sources-debian10.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb [arch=arm64] http://archive.debian.org/debian buster main
deb [arch=arm64] http://archive.debian.org/debian-security buster/updates main
================================================
FILE: go/base-arm/sources-debian11.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb [arch=arm64] http://deb.debian.org/debian bullseye main
deb [arch=arm64] http://deb.debian.org/debian bullseye-updates main
deb [arch=arm64] http://deb.debian.org/debian-security/ bullseye-security main
================================================
FILE: go/base-arm/sources-debian12.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb [arch=arm64] http://deb.debian.org/debian bookworm main
deb [arch=arm64] http://deb.debian.org/debian-security/ bookworm-security main
================================================
FILE: go/base-arm/sources-debian8.list
================================================
deb [arch=arm64] http://archive.debian.org/debian jessie main
================================================
FILE: go/base-arm/sources-debian9.list
================================================
deb [arch=arm64] http://archive.debian.org/debian stretch main
deb [arch=arm64] http://archive.debian.org/debian-security stretch/updates main
================================================
FILE: go/darwin/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
FROM --platform=linux/amd64 docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian{{ .DEBIAN_VERSION }}-amd64 AS build-llvm-apple
{{- end }}
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}
RUN \
apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install -qq -y --no-install-recommends --allow-unauthenticated \
clang \
llvm \
cmake \
patch \
{{- if and (ne .DEBIAN_VERSION "10") (ne .DEBIAN_VERSION "11") (ne .DEBIAN_VERSION "12") }}
python \
{{- end }}
libssl-dev \
libxml2-dev \
lzma-dev \
llvm-dev \
uuid-dev \
&& rm -rf /var/lib/apt/lists/*
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12") }}
ARG OSXCROSS_PATH=/usr/local/osxcross
COPY --from=build-llvm-apple /osxcross.tar.gz /tmp/osxcross.tar.gz
RUN tar -xzf /tmp/osxcross.tar.gz -C / \
&& rm /tmp/osxcross.tar.gz
{{- else }}
ARG OSXCROSS_PATH=/usr/osxcross
{{- if or (eq .DEBIAN_VERSION "8") (eq .DEBIAN_VERSION "9") }}
ARG OSXCROSS_REV=3034f7149716d815bc473d0a7b35d17e4cf175aa
ARG SDK_VERSION=10.11
{{- else }}
ARG OSXCROSS_REV=f873f534c6cdb0776e457af8c7513da1e02abe59
ARG SDK_VERSION=12.3
{{- end }}
ARG DARWIN_VERSION=15
ARG OSX_VERSION_MIN=10.10
COPY sdks/MacOSX${SDK_VERSION}.sdk.tar.xz /tmp/osxcross/tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz
RUN \
cd /tmp/osxcross \
&& curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" \
| tar -C /tmp/osxcross --strip=1 -xzf - \
&& UNATTENDED=yes ./build.sh >/dev/null \
&& mv target "${OSXCROSS_PATH}" \
&& rm -rf /tmp/osxcross "/usr/osxcross/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man"
{{- end }}
ENV PATH=$PATH:$OSXCROSS_PATH/bin
# Add osxcross libraries to the library PATH
ENV LD_LIBRARY_PATH=$OSXCROSS_PATH/lib:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
COPY rootfs /
# Basic test
RUN cd / \
&& o64-clang helloWorld.c -o helloWorld.x86_64 \
&& file helloWorld.x86_64 \
&& file helloWorld.x86_64 | grep -c 'Mach-O 64-bit x86_64'
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
RUN cd / \
&& oa64-clang helloWorld.c -o helloWorld.arm64 \
&& file helloWorld.arm64 \
&& file helloWorld.arm64 | grep -c 'Mach-O 64-bit arm64'
RUN cd / \
&& lipo -create -output helloWorld.universal helloWorld.x86_64 helloWorld.arm64 \
&& file helloWorld.universal | grep 'Mach-O universal binary' \
&& rm helloWorld.*
{{- end }}
# MacOSX10.14 SDK does not have 32bits compiler
{{- if and (ne .DEBIAN_VERSION "10") (ne .DEBIAN_VERSION "11") (ne .DEBIAN_VERSION "12")}}
RUN cd / \
&& o32-clang helloWorld.c -o helloWorld.i368 \
&& file helloWorld.i368 \
&& file helloWorld.i368 | grep -c 'Mach-O i386' \
&& rm helloWorld.*
{{- end }}
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/darwin/Makefile
================================================
include ../Makefile.common
ifeq ($(DOCKER_MULTIARCH),1)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
================================================
FILE: go/darwin/rootfs/compilers.yaml
================================================
---
darwin:
amd64:
CC: o64-clang
CXX: o64-clang++
================================================
FILE: go/darwin/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/darwin-arm64/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
FROM --platform=linux/arm64 docker.elastic.co/beats-dev/golang-crossbuild:llvm-apple-debian{{ .DEBIAN_VERSION }}-arm64 AS build-llvm-apple
{{- end }}
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base-arm${TAG_EXTENSION}
{{- if and (ne .DEBIAN_VERSION "10") (ne .DEBIAN_VERSION "11") (ne .DEBIAN_VERSION "12")}}
RUN echo "This Docker image will work only with Debian >10" && exit 1
{{- end }}
RUN \
apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install -qq -y --no-install-recommends --allow-unauthenticated \
cmake \
patch \
libssl-dev \
libxml2-dev \
lzma-dev \
uuid-dev \
&& rm -rf /var/lib/apt/lists/*
COPY --from=build-llvm-apple /llvm-apple-Linux.tar.gz /tmp/llvm-apple-Linux.tar.gz
RUN tar -xzf /tmp/llvm-apple-Linux.tar.gz --strip 1 -C /usr/local \
&& rm /tmp/llvm-apple-Linux.tar.gz
ARG OSXCROSS_PATH=/usr/local/osxcross
COPY --from=build-llvm-apple /osxcross.tar.gz /tmp/osxcross.tar.gz
RUN tar -xzf /tmp/osxcross.tar.gz -C / \
&& rm /tmp/osxcross.tar.gz
ENV PATH=$PATH:$OSXCROSS_PATH/bin
# Add osxcross libraries to the library PATH
ENV LD_LIBRARY_PATH=$OSXCROSS_PATH/lib:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
COPY rootfs /
# Basic test
RUN cd / \
&& o64-clang helloWorld.c -o helloWorld.x86_64 \
&& file helloWorld.x86_64 \
&& file helloWorld.x86_64 | grep -c 'Mach-O 64-bit x86_64'
RUN cd / \
&& oa64-clang helloWorld.c -o helloWorld.arm64 \
&& file helloWorld.arm64 \
&& file helloWorld.arm64 | grep -c 'Mach-O 64-bit arm64'
RUN cd / \
&& oa64e-clang helloWorld.c -o helloWorld.arm64e \
&& file helloWorld.arm64e \
&& file helloWorld.arm64e | grep -c 'Mach-O 64-bit arm64'
RUN cd / \
&& lipo -create -output helloWorld.universal helloWorld.x86_64 helloWorld.arm64e \
&& file helloWorld.universal | grep 'Mach-O universal binary' \
&& rm helloWorld.*
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/darwin-arm64/Makefile
================================================
include ../Makefile.common
ifeq ($(DOCKER_MULTIARCH),1)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
================================================
FILE: go/darwin-arm64/rootfs/compilers.yaml
================================================
---
darwin:
arm64:
CC: oa64-clang
CXX: oa64-clang++
================================================
FILE: go/darwin-arm64/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/llvm-apple/Dockerfile.tmpl
================================================
ARG DEBIAN_VERSION=9
FROM debian:${DEBIAN_VERSION} AS BUILD_LLVM_APPLE
ARG DEBIAN_VERSION
# Replace sources.list in order to use archive.debian.org.
COPY sources-debian${DEBIAN_VERSION}.list /etc/apt/sources.list
RUN apt-get -o Acquire::Check-Valid-Until=false update -y --no-install-recommends --allow-unauthenticated \
&& apt-get upgrade -y --no-install-recommends --allow-unauthenticated \
&& apt-get dist-upgrade -y --no-install-recommends --allow-unauthenticated \
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
build-essential \
ca-certificates \
curl \
git \
gnupg \
make \
file \
flex \
bison \
cmake \
patch \
libssl-dev \
libxml2-dev \
lzma-dev \
uuid-dev \
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
binutils-multiarch \
binutils-multiarch-dev \
python3-venv \
python3-pip \
python3 \
{{- end }}
&& rm -rf /var/lib/apt/lists/*
#https://www.llvm.org/docs/CMake.html
#https://github.com/apple/llvm-project
RUN mkdir -p /tmp/llvm-project && cd /tmp/llvm-project \
&& curl -sSL "https://github.com/apple/llvm-project/archive/refs/tags/swift-5.6.3-RELEASE.tar.gz" \
| tar -C /tmp/llvm-project --strip=1 -xzf - \
&& mkdir build && cd build \
&& cmake -DLLVM_ENABLE_PROJECTS="clang" \
-DCMAKE_BUILD_TYPE="Release" \
-DLLVM_TARGETS_TO_BUILD="X86;AArch64" \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=Off \
-DLLVM_ENABLE_BACKTRACES=Off \
-DLLVM_BUILD_32_BITS=OFF \
/tmp/llvm-project/llvm \
&& cmake --build . \
&& cmake --build . --target package \
&& tar -xzf LLVM-*-Linux.tar.gz --strip 1 -C /usr/local
# TODO think about replace this with the Docker image already created at https://github.com/crazy-max/docker-osxcross
ARG OSX_SDK="MacOSX12.3.sdk"
# Packaging the SDK on macOS https://github.com/tpoechtrager/osxcross#packaging-the-sdk
# alternative SDK already generated
ARG OSXCROSS_PATH=/usr/local/osxcross
ARG OSXCROSS_REV=f873f534c6cdb0776e457af8c7513da1e02abe59
ARG OSX_VERSION_MIN=10.10
RUN mkdir -p /tmp/osxcross
# https://raw.githubusercontent.com/crazy-max/docker-osxcross/main/patches/lcxx.patch
COPY lcxx.patch /tmp/osxcross/lcxx.patch
COPY sdks/${OSX_SDK}.tar.xz /tmp/osxcross/tarballs/${OSX_SDK}.tar.xz
RUN \
cd /tmp/osxcross \
&& curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" \
| tar -C /tmp/osxcross --strip=1 -xzf - \
&& patch -p1 < lcxx.patch \
&& UNATTENDED=1 ENABLE_COMPILER_RT_INSTALL=1 OSX_VERSION_MIN=${OSX_VERSION_MIN} TARGET_DIR=${OSXCROSS_PATH} ./build.sh >/dev/null \
&& rm -rf "/usr/osxcross/SDK/${OSX_SDK}/usr/share/man" \
&& tar -czf osxcross.tar.gz ${OSXCROSS_PATH}
FROM debian:stable-slim
COPY --from=BUILD_LLVM_APPLE /tmp/llvm-project/build/LLVM-*-Linux.tar.gz /llvm-apple-Linux.tar.gz
COPY --from=BUILD_LLVM_APPLE /tmp/osxcross/osxcross.tar.gz /osxcross.tar.gz
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
ENTRYPOINT /bin/bash
================================================
FILE: go/llvm-apple/Makefile
================================================
include ../Makefile.common
SUFFIX := $(shell basename $(CURDIR))
TAG := $(REPOSITORY)/$(NAME):$(SUFFIX)$(TAG_EXTENSION)
ifeq ($(DOCKER_MULTIARCH),1)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
copy-npcap:
@echo "NOOP"
build:
@echo ">> Building $(TAG)"
@go run $(SELF_DIR)/../template.go -t Dockerfile.tmpl -o Dockerfile
@$(DOCKER_CMD) -t "$(TAG)" \
--build-arg REPOSITORY=$(REPOSITORY) \
--build-arg VERSION=$(VERSION) \
--build-arg DEBIAN_VERSION=$(DEBIAN_VERSION) \
--build-arg TAG_EXTENSION=$(TAG_EXTENSION) \
--build-arg IMAGE="$(TAG)" \
--build-arg VCS_REF="$(VCS_REF)" \
--build-arg VCS_URL="$(VCS_URL)" \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
.
atomic-push:
@echo ">> Pushing $(TAG)"
@docker push "$(TAG)"
================================================
FILE: go/llvm-apple/lcxx.patch
================================================
diff --git a/wrapper/target.cpp b/wrapper/target.cpp
index 82bf65c..a2520e2 100644
--- a/wrapper/target.cpp
+++ b/wrapper/target.cpp
@@ -741,6 +741,9 @@ bool Target::setup() {
(stdlib == StdLib::libstdcxx && usegcclibs)) {
fargs.push_back("-nostdinc++");
fargs.push_back("-Qunused-arguments");
+ if ((SDKOSNum >= OSVersion(11, 1)) && (stdlib == StdLib::libcxx)) {
+ fargs.push_back("-lc++");
+ }
}
if (stdlib == StdLib::libstdcxx && usegcclibs && targetarch.size() < 2 &&
================================================
FILE: go/llvm-apple/sources-debian10.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb http://archive.debian.org/debian buster main
deb http://archive.debian.org/debian-security buster/updates main
================================================
FILE: go/llvm-apple/sources-debian11.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb http://deb.debian.org/debian bullseye main
deb http://deb.debian.org/debian bullseye-updates main
deb http://deb.debian.org/debian-security/ bullseye-security main
================================================
FILE: go/llvm-apple/sources-debian12.list
================================================
# see https://wiki.debian.org/CrossToolchains
deb http://deb.debian.org/debian bookworm main
deb http://deb.debian.org/debian-security/ bookworm-security main
================================================
FILE: go/main/.dockerignore
================================================
Makefile
================================================
FILE: go/main/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}
RUN \
dpkg --add-architecture i386 \
&& apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install -qq -y --no-install-recommends --allow-unauthenticated \
clang \
g++ \
gcc \
gcc-multilib \
libc6-dev \
libc6-dev-i386 \
linux-libc-dev:i386 \
mingw-w64 \
mingw-w64-tools \
patch \
xz-utils \
unzip
{{- if ne .DEBIAN_VERSION "7" }}
# librpm-dev
RUN apt install -y --no-install-recommends --allow-unauthenticated\
librpm-dev \
libxml2-dev \
libsqlite3-dev
RUN apt install -y --no-install-recommends --allow-unauthenticated\
libsystemd-dev
{{- end }}
{{- if or (eq .DEBIAN_VERSION "9") (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
# msitools
RUN apt install -y --no-install-recommends --allow-unauthenticated\
msitools
{{- end }}
RUN rm -rf /var/lib/apt/lists/*
COPY rootfs /
# Basic test
RUN cd / \
&& gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& file helloWorld | cut -d "," -f 2 | grep -c 'x86-64' \
&& rm helloWorld.c helloWorld
RUN cd /libpcap/libpcap-1.8.1 \
&& cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-i386 \
&& cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-amd64 \
&& cd /libpcap/libpcap-1.8.1-i386 \
&& CFLAGS="-m32" LDFLAGS="-m32" ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no \
&& make \
&& cd /libpcap/libpcap-1.8.1-amd64 \
&& ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no \
&& make
COPY sdks/WpdPack_4_1_2.zip .
RUN mkdir -p /libpcap/win \
&& echo "ea799cf2f26e4afb1892938070fd2b1ca37ce5cf75fec4349247df12b784edbd WpdPack_4_1_2.zip" | sha256sum -c - \
&& unzip WpdPack_4_1_2.zip -d /libpcap/win \
&& rm WpdPack_4_1_2.zip \
&& cd /libpcap/win/WpdPack \
&& curl -sSLO https://raw.githubusercontent.com/elastic/beats/master/packetbeat/lib/windows-64/wpcap.dll \
&& echo "0948518b229fb502b9c063966fc3afafbb749241a1c184f6eb7d532e00bce1d8 wpcap.dll" | sha256sum -c - \
&& gendef wpcap.dll \
&& x86_64-w64-mingw32-dlltool \
--as-flags=--64 \
-m i386:x86-64 \
-k \
--output-lib /libpcap/win/WpdPack/Lib/x64/libwpcap.a \
--input-def /libpcap/win/WpdPack/wpcap.def
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/main/Makefile
================================================
include ../Makefile.common
================================================
FILE: go/main/rootfs/compilers.yaml
================================================
---
windows:
386:
CC: i686-w64-mingw32-gcc
CXX: i686-w64-mingw32-g++
amd64:
CC: x86_64-w64-mingw32-gcc
CXX: x86_64-w64-mingw32-g++
darwin:
386:
CC: o32-clang
CXX: o32-clang++
amd64:
CC: o64-clang
CXX: o64-clang++
linux:
386:
CC: gcc
CXX: g++
amd64:
CC: gcc
CXX: g++
================================================
FILE: go/main/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/mips/.dockerignore
================================================
Makefile
================================================
FILE: go/mips/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}
RUN dpkg --add-architecture mips64el \
&& apt update -y --no-install-recommends \
&& apt upgrade -y --no-install-recommends \
&& apt full-upgrade -y --no-install-recommends \
&& apt install -qq -y --no-install-recommends \
crossbuild-essential-mipsel \
gcc-mips64el-linux-gnuabi64 \
g++-mips64el-linux-gnuabi64 \
gcc-mips64-linux-gnuabi64 \
g++-mips64-linux-gnuabi64 \
linux-libc-dev-mips64el-cross
RUN apt install -qq -y \
libc-dev:mips64el \
libpopt-dev:mips64el \
linux-libc-dev:mips64el
{{- if eq .DEBIAN_VERSION "9" }}
# librpm-dev
RUN apt install -y \
libelf1:mips64el \
libicu-dev:mips64el \
libicu57:mips64el \
librpm-dev:mips64el \
librpm3:mips64el \
librpmio3:mips64el \
librpmbuild3:mips64el \
librpmsign3:mips64el \
libxml2-dev:mips64el \
libsqlite3-dev:mips64el \
libnss3:mips64el \
libsqlite3-0:mips64el \
libxml2:mips64el \
libsqlite3-0:mips64el
# libsystemd-dev
# RUN apt install -y \
# libsystemd-dev:mips64el libsystemd0:mips64el liblz4-1:mips64el
{{- end }}
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
# librpm-dev
RUN apt install -y \
librpm-dev:mips64el
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:mips64el
{{- end }}
RUN rm -rf /var/lib/apt/lists/*
COPY rootfs /
# Basic test
RUN cd / \
&& mips64el-linux-gnuabi64-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& readelf -h helloWorld | grep -c 'MIPS R3000' \
&& readelf -h helloWorld | grep -c 'ELF64' \
&& readelf -h helloWorld | grep -c "little endian" \
&& rm helloWorld
# Basic test
RUN cd / \
&& mips64-linux-gnuabi64-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& readelf -h helloWorld | grep -c 'MIPS R3000' \
&& readelf -h helloWorld | grep -c 'ELF64' \
&& readelf -h helloWorld | grep -c "big endian" \
&& rm helloWorld.c helloWorld
RUN cd /libpcap/libpcap-1.8.1 \
&& cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-mips64 \
&& cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-mips64el \
&& cd /libpcap/libpcap-1.8.1-mips64 \
&& CC=mips64-linux-gnuabi64-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=mips64-unknown-linux-gnu --with-pcap=linux \
&& make \
&& cd /libpcap/libpcap-1.8.1-mips64el \
&& CC=mips64el-linux-gnuabi64-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=mips64el-unknown-linux-gnu --with-pcap=linux \
&& make
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/mips/Makefile
================================================
include ../Makefile.common
================================================
FILE: go/mips/rootfs/compilers.yaml
================================================
---
linux:
mips64le:
CC: mips64el-linux-gnuabi64-gcc
CXX: mips64el-linux-gnuabi64-g++
mips64:
CC: mips64-linux-gnuabi64-gcc
CXX: mips64-linux-gnuabi64-g++
================================================
FILE: go/mips/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/mips32/.dockerignore
================================================
Makefile
================================================
FILE: go/mips32/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}
RUN dpkg --add-architecture mips \
&& apt update -y --no-install-recommends \
&& apt upgrade -y --no-install-recommends \
&& apt full-upgrade -y --no-install-recommends \
&& apt install -qq -y --no-install-recommends \
crossbuild-essential-mipsel \
gcc-mips-linux-gnu \
g++-mips-linux-gnu \
linux-libc-dev-mips-cross
RUN apt install -qq -y \
libc-dev:mips \
libpopt-dev:mips \
linux-libc-dev:mips
{{- if eq .DEBIAN_VERSION "9" }}
# librpm-dev
RUN apt install -y \
libelf1:mips \
libicu-dev:mips \
libicu57:mips \
librpm-dev:mips \
librpm3:mips \
librpmio3:mips \
librpmbuild3:mips \
librpmsign3:mips \
libxml2-dev:mips \
libsqlite3-dev:mips \
libnss3:mips \
libsqlite3-0:mips \
libxml2:mips \
libsqlite3-0:mips
# libsystemd-dev
# RUN apt install -y \
# libsystemd-dev:mips libsystemd0:mips liblz4-1:mips
{{- end }}
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
# librpm-dev
RUN apt install -y \
librpm-dev:mips
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:mips
{{- end }}
RUN rm -rf /var/lib/apt/lists/*
COPY rootfs /
# Basic test
RUN cd / \
&& mips-linux-gnu-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& readelf -h helloWorld | grep -c 'MIPS R3000' \
&& readelf -h helloWorld | grep -c 'ELF32' \
&& readelf -h helloWorld | grep -c "big endian" \
&& rm helloWorld
# Basic test
RUN cd / \
&& mipsel-linux-gnu-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& readelf -h helloWorld | grep -c 'MIPS R3000' \
&& readelf -h helloWorld | grep -c 'ELF32' \
&& readelf -h helloWorld | grep -c "little endian" \
&& rm helloWorld.c helloWorld
RUN cd /libpcap/libpcap-1.8.1 \
&& cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-mips \
&& cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-mipsel \
&& cd /libpcap/libpcap-1.8.1-mips \
&& CC=mips-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=mips-unknown-linux-gnu --with-pcap=linux \
&& make \
&& cd /libpcap/libpcap-1.8.1-mipsel \
&& CC=mipsel-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=mipsel-unknown-linux-gnu --with-pcap=linux \
&& make
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/mips32/Makefile
================================================
include ../Makefile.common
================================================
FILE: go/mips32/rootfs/compilers.yaml
================================================
---
linux:
mips:
CC: mips-linux-gnu-gcc
CXX: mips-linux-gnu-g++
mipsle:
CC: mipsel-linux-gnu-gcc
CXX: mipsel-linux-gnu-g++
================================================
FILE: go/mips32/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/npcap/.dockerignore
================================================
Makefile
================================================
FILE: go/npcap/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-main${TAG_EXTENSION}
COPY lib/{{.NPCAP_FILE}} /installer/
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/npcap/Makefile
================================================
include ../Makefile.common
SUFFIX = $(SUFFIX_NPCAP_VERSION)
push:
@[ "$(REPOSITORY)" = "$(NPCAP_REPOSITORY)" ] \
&& $(MAKE) atomic-push \
|| echo "WARNING: $(SUFFIX_NPCAP_VERSION) can only be published in $(NPCAP_REPOSITORY)"
================================================
FILE: go/npcap/lib/.gitkeep
================================================
================================================
FILE: go/ppc/.dockerignore
================================================
Makefile
================================================
FILE: go/ppc/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}
RUN dpkg --add-architecture ppc64el \
&& apt update -y --no-install-recommends \
&& apt upgrade -y --no-install-recommends \
&& apt full-upgrade -y --no-install-recommends \
&& apt install -qq -y --no-install-recommends \
g++-powerpc64-linux-gnu \
gcc-powerpc64-linux-gnu \
crossbuild-essential-ppc64el
RUN apt install -qq -y \
libc-dev:ppc64el \
libpopt-dev:ppc64el \
linux-libc-dev:ppc64el
{{- if eq .DEBIAN_VERSION "9" }}
RUN apt install -qq -y \
libelf1:ppc64el \
libicu-dev:ppc64el \
libicu57:ppc64el \
librpm-dev:ppc64el \
libxml2-dev:ppc64el \
libxml2:ppc64el \
librpm3:ppc64el \
librpmio3:ppc64el \
librpmbuild3:ppc64el \
librpmsign3:ppc64el \
libsqlite3-dev:ppc64el \
libnss3:ppc64el \
libsqlite3-0:ppc64el
# RUN apt install -y \
# libsystemd-dev:ppc64el libsystemd0:ppc64el liblz4-1:ppc64el
{{- end }}
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
# librpm-dev
RUN apt install -y \
librpm-dev:ppc64el
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:ppc64el
{{- end }}
RUN rm -rf /var/lib/apt/lists/*
COPY rootfs /
# Basic test
RUN cd / \
&& powerpc64le-linux-gnu-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& readelf -h helloWorld | grep -c 'PowerPC64' \
&& readelf -h helloWorld | grep -c 'ELF64' \
&& readelf -h helloWorld | grep -c "little endian" \
&& rm helloWorld.c helloWorld
RUN cd /libpcap/libpcap-1.8.1 \
&& cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-ppc64 \
&& cp -R /libpcap/libpcap-1.8.1 /libpcap/libpcap-1.8.1-ppc64el \
&& cd /libpcap/libpcap-1.8.1-ppc64 \
&& CC=powerpc64-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=ppc64-unknown-linux-gnu --with-pcap=linux \
&& make \
&& cd /libpcap/libpcap-1.8.1-ppc64el \
&& CC=powerpc64le-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=ppc64el-unknown-linux-gnu --with-pcap=linux \
&& make
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/ppc/Makefile
================================================
include ../Makefile.common
================================================
FILE: go/ppc/rootfs/compilers.yaml
================================================
---
linux:
ppc64:
CC: powerpc64-linux-gnu-gcc
CXX: powerpc64-linux-gnu-g++
ppc64le:
CC: powerpc64le-linux-gnu-gcc
CXX: powerpc64le-linux-gnu-g++
================================================
FILE: go/ppc/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/s390x/.dockerignore
================================================
Makefile
================================================
FILE: go/s390x/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION}
RUN dpkg --add-architecture s390x \
&& apt update -y --no-install-recommends \
&& apt upgrade -y --no-install-recommends \
&& apt full-upgrade -y --no-install-recommends \
&& apt install -qq -y --no-install-recommends \
g++-s390x-linux-gnu \
gcc-s390x-linux-gnu
RUN apt install -qq -y \
libc-dev:s390x \
libpopt-dev:s390x \
linux-libc-dev:s390x
{{- if eq .DEBIAN_VERSION "9" }}
RUN apt install -qq -y \
libelf1:s390x \
libicu-dev:s390x \
libicu57:s390x \
librpm-dev:s390x \
libxml2-dev:s390x \
libxml2:s390x \
librpm3:s390x \
librpmio3:s390x \
librpmbuild3:s390x \
librpmsign3:s390x \
libsqlite3-dev:s390x \
libnss3:s390x \
libsqlite3-0:s390x
# RUN apt install -y \
# libsystemd-dev:s390x libsystemd0:s390x liblz4-1:s390x
{{- end }}
{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}}
# librpm-dev
RUN apt install -y \
librpm-dev:s390x
# libsystemd-dev
RUN apt install -y \
libsystemd-dev:s390x
{{- end }}
RUN rm -rf /var/lib/apt/lists/*
COPY rootfs /
# Basic test
RUN cd / \
&& s390x-linux-gnu-gcc helloWorld.c -o helloWorld \
&& file helloWorld \
&& readelf -h helloWorld \
&& readelf -h helloWorld | grep -c 'IBM S/390' \
&& readelf -h helloWorld | grep -c 'ELF64' \
&& readelf -h helloWorld | grep -c "big endian" \
&& rm helloWorld.c helloWorld
RUN cd /libpcap/libpcap-1.8.1 \
&& CC=s390x-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=s390x-ibm-linux-gnu --with-pcap=linux \
&& make
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/s390x/Makefile
================================================
include ../Makefile.common
================================================
FILE: go/s390x/rootfs/compilers.yaml
================================================
---
linux:
s390x:
CC: s390x-linux-gnu-gcc
CXX: s390x-linux-gnu-g++
================================================
FILE: go/s390x/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/windows-arm64/Dockerfile.tmpl
================================================
ARG REPOSITORY=docker.elastic.co/beats-dev
ARG VERSION=1.26.2
ARG TAG_EXTENSION=''
FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base-arm${TAG_EXTENSION}
#ARG LLVM_MINGW64_VER=20250826
ARG LLVM_MINGW64_VER=20250910
ARG LLVM_MINGW_UBUNTU_REL='22.04'
ARG LLVM_MINGW64_SRC="https://github.com/mstorsjo/llvm-mingw/releases/download"
ENV LLVM_MINGW64_VER="${LLVM_MINGW64_VER}"
ENV LLVM_MINGW64_SRC="$LLVM_MINGW64_SRC"
{{- if ne .DEBIAN_VERSION "12"}}
RUN echo "This Docker image will work only with Debian >12" && exit 1
{{- end }}
RUN \
apt-get -o Acquire::Check-Valid-Until=false update \
&& apt-get install -qq -y --no-install-recommends --allow-unauthenticated \
cmake \
patch \
libssl-dev \
libxml2-dev \
lzma-dev \
uuid-dev \
make \
bash \
wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /tmp
COPY --chmod=0755 scripts/setup-llvm-mingw64.sh /tmp/
RUN /tmp/setup-llvm-mingw64.sh
COPY --chmod=0755 scripts/install-llvm-mingw64.sh /tmp/install-llvm-mingw64.sh
RUN /tmp/install-llvm-mingw64.sh /tmp/llvm-mingw64 && rm -rf /tmp/*
COPY rootfs /
# Basic test
RUN which aarch64-w64-mingw32-gcc
RUN cd / \
&& aarch64-w64-mingw32-gcc helloWorld.c -o helloWorld.arm64 \
&& file helloWorld.arm64 \
&& file helloWorld.arm64 | grep -c 'PE32+ executable (console) Aarch64, for MS Windows'
RUN cd / \
&& aarch64-w64-mingw32uwp-gcc helloWorld.c -o helloWorld.arm64e \
&& file helloWorld.arm64e \
&& file helloWorld.arm64e | grep -c 'PE32+ executable (console) Aarch64, for MS Windows'
ENV CGO_ENABLED=1
#ENV CC aarch64-w64-mingw32-gcc
#ENV CXX aarch64-w64-mingw32-g++
ENV CGO_FLAGS="$CGO_FLAGS -I/usr/generic-w64-mingw32/include"
ENV CGO_CFLAGS="-fno-addrsig"
RUN go env
RUN aarch64-w64-mingw32-gcc --version
RUN go clean -cache -modcache -i -r
# Build-time metadata as defined at http://label-schema.org.
ARG BUILD_DATE
ARG IMAGE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name=$IMAGE \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url=$VCS_URL \
org.label-schema.schema-version="1.0"
================================================
FILE: go/windows-arm64/Makefile
================================================
include ../Makefile.common
ifeq ($(DOCKER_MULTIARCH),1)
DOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh
push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
atomic-push:
@echo "Already done by buildx (.buildkite/scripts/buildx.sh)."
endif
================================================
FILE: go/windows-arm64/rootfs/compilers.yaml
================================================
---
windows:
arm64:
CC: aarch64-w64-mingw32-gcc
CXX: aarch64-w64-mingw32-g++
================================================
FILE: go/windows-arm64/rootfs/helloWorld.c
================================================
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
================================================
FILE: go/windows-arm64/scripts/install-llvm-mingw64.sh
================================================
#!/usr/bin/env bash
#
# Copied from: https://github.com/x1unix/docker-go-mingw/tree/20dfaff6efe8fe3a4ff588a58ccb31646cd2fd60
#
set -e
set -o pipefail
trap 'echo "$0: Error on line $LINENO" >&2' ERR
src="$1"
if [ -z "$src" ]; then
echo "Error: missing source dir"
exit 1
fi
base_dir='/usr'
echo ":: Installing llvm-mingw64..."
echo "Source dir: $src"
cd "$src" || exit 1
find . -mindepth 1 -maxdepth 1 -type d ! -name . | while read -r subdir; do
dst_dir="$(basename "$subdir")"
case "$dst_dir" in
bin)
perm=755
;;
*)
perm=644
;;
esac
find "$subdir" -type f | while read -r file; do
dst="$base_dir/${file/.\//}"
mkdir -p "$(dirname "$dst")"
install -m $perm "$file" "$dst"
done
done
echo ":: Restoring symlinks..."
while IFS= read -r line; do
link_src=$(echo "$line" | awk '{print $1}')
link_src="$base_dir/$link_src"
link_dest=$(echo "$line" | awk '{print $2}')
link_dest="$(realpath "$base_dir/$link_dest")"
ln -s "$link_dest" "$link_src"
done <symlinks.txt
echo ":: Creating symlink for aarch64-w64-mingw32 headers..."
if [ ! -d "$base_dir/aarch64-w64-mingw32/include" ]; then
if [ -d "$base_dir/generic-w64-mingw32/include" ]; then
ln -s "$base_dir/generic-w64-mingw32/include" "$base_dir/aarch64-w64-mingw32/include"
echo "Created symlink: $base_dir/aarch64-w64-mingw32/include -> $base_dir/generic-w64-mingw32/include"
else
echo "Warning: $base_dir/generic-w64-mingw32/include does not exist"
fi
else
echo "Include directory already exists, skipping symlink creation"
fi
echo ":: Cleanup"
cd ..
rm -rf "$src"
================================================
FILE: go/windows-arm64/scripts/setup-llvm-mingw64.sh
================================================
#!/usr/bin/env bash
#
# Copied from: https://github.com/x1unix/docker-go-mingw/tree/20dfaff6efe8fe3a4ff588a58ccb31646cd2fd60
#
set -e
set -o pipefail
trap 'echo "$0: Error on line $LINENO" >&2' ERR
if [ -z "$LLVM_MINGW64_SRC" ]; then
echo "Error: LLVM_MINGW64_SRC is undefined"
env
exit 1
fi
if [ -z "$LLVM_MINGW_UBUNTU_REL" ]; then
echo "Error: LLVM_MINGW_UBUNTU_REL is undefined"
env
exit 1
fi
if [ -z "$LLVM_MINGW64_VER" ]; then
echo "Error: LLVM_MINGW64_VER is undefined"
env
exit 1
fi
apt update && apt install xz-utils --yes
case "$(uname -m)" in
aarch64 | arm64)
m_arch="aarch64"
;;
x86_64 | amd64)
m_arch="x86_64"
;;
*)
echo "Error: unsupported architecture $(uname -m)"
exit 1
;;
esac
pkg_dir="llvm-mingw-$LLVM_MINGW64_VER-ucrt-ubuntu-$LLVM_MINGW_UBUNTU_REL-$m_arch"
pkg_file="$pkg_dir.tar.xz"
src_url="$LLVM_MINGW64_SRC/$LLVM_MINGW64_VER/$pkg_file"
echo ":: Downloading $src_url ..."
wget "$src_url"
# wget -q --spider "$src_url"
if [ ! -f "$pkg_file" ]; then
echo "Error: can't find downloaded file $pkg_file"
ls -la
exit 1
fi
echo ":: Extracting file..."
tar -xf "$pkg_file"
rm "$pkg_file"
echo ":: Preparing file list..."
mv "$pkg_dir" llvm-mingw64
cd llvm-mingw64
# Keep llvm-mingw64 only for arm target to avoid conflict with gcc-mingw64
# Remove x86_64 and i686 binaries but keep the generic headers
rm -f bin/x86_64* bin/i686*
rm -rf i686-w64-mingw32/bin i686-w64-mingw32/lib
rm -rf x86_64-w64-mingw32/bin x86_64-w64-mingw32/lib
# Keep the include directories as they contain shared headers
# Only remove the i686 and x86_64 directories if they don't contain needed includes
if [ -d "i686-w64-mingw32" ]; then
find i686-w64-mingw32 -mindepth 1 ! -path "*/include/*" -delete
if [ -z "$(ls -A i686-w64-mingw32)" ]; then
rm -rf i686-w64-mingw32
fi
fi
if [ -d "x86_64-w64-mingw32" ]; then
find x86_64-w64-mingw32 -mindepth 1 ! -path "*/include/*" -delete
if [ -z "$(ls -A x86_64-w64-mingw32)" ]; then
rm -rf x86_64-w64-mingw32
fi
fi
# Backup symlinks
find . -type l | while read -r symlink; do
src="${symlink/.\//}"
dst="$(dirname "$src")/$(readlink "$symlink")"
echo "$src $dst" >>symlinks.txt
rm "$symlink"
done
================================================
FILE: template.go
================================================
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package main
import (
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
"text/template"
)
var usageText = `
Usage: template -t <tmpl file> [-o output]
This command renders the specified template file using the Go text/template
package. It makes the current environment available as variables.
Options:
`[1:]
var (
templateFile string
outputFile string
)
func init() {
flag.StringVar(&templateFile, "t", "", "template file")
flag.StringVar(&outputFile, "o", "", "output file")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, usageText)
flag.PrintDefaults()
}
}
func main() {
flag.Parse()
log.SetFlags(0)
if templateFile == "" {
log.Fatal("Template file (-t) is required.")
}
t := template.Must(template.
New(filepath.Base(templateFile)).
ParseFiles(templateFile))
data := envVars()
buf := new(bytes.Buffer)
if err := t.Execute(buf, data); err != nil {
log.Fatal(err)
}
if outputFile == "-" || outputFile == "" {
fmt.Println(buf.String())
} else {
if err := ioutil.WriteFile(outputFile, buf.Bytes(), 0644); err != nil {
log.Fatal(err)
}
}
}
func envVars() map[string]string {
env := map[string]string{}
for _, e := range os.Environ() {
parts := strings.SplitN(e, "=", 2)
env[parts[0]] = parts[1]
}
return env
}
gitextract_x3ml7gzw/ ├── .buildkite/ │ ├── fpm-pipeline.yml │ ├── hooks/ │ │ ├── pre-command │ │ └── pre-exit │ ├── llvm-apple-pipeline.yml │ ├── pipeline.yml │ ├── pull-requests.json │ └── scripts/ │ ├── build.sh │ ├── buildx.sh │ ├── common.sh │ ├── llvm-apple/ │ │ ├── build.sh │ │ └── publish.sh │ ├── llvm-fpm/ │ │ └── build_and_publish.sh │ ├── post-release.sh │ ├── publish.sh │ └── validate-go-version.sh ├── .editorconfig ├── .github/ │ ├── CODEOWNERS │ ├── actions/ │ │ └── bump-golang/ │ │ └── action.yml │ ├── dependabot.yml │ ├── release-drafter.yml │ ├── updatecli.d/ │ │ ├── bump-go-version.sh │ │ └── bump-golang.yml │ └── workflows/ │ ├── bump-golang-previous.yml │ ├── bump-golang.yml │ ├── catalog-info.yml │ └── release-drafter.yml ├── .gitignore ├── .go-version ├── .mergify.yml ├── .updatecli-version ├── LICENSE ├── Makefile ├── Makefile.common ├── NPCAP.md ├── README.md ├── RELEASE.md ├── catalog-info.yaml ├── fpm/ │ ├── .dockerignore │ ├── Dockerfile.tmpl │ ├── Makefile │ └── rootfs/ │ └── entrypoint.sh ├── go/ │ ├── Makefile │ ├── Makefile.common │ ├── Makefile.debian10 │ ├── Makefile.debian11 │ ├── Makefile.debian12 │ ├── Makefile.debian7 │ ├── Makefile.debian8 │ ├── Makefile.debian9 │ ├── arm/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── armel/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── armhf/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── base/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ ├── rootfs/ │ │ │ └── entrypoint.go │ │ ├── sources-debian10.list │ │ ├── sources-debian11.list │ │ ├── sources-debian12.list │ │ ├── sources-debian7.list │ │ ├── sources-debian8.list │ │ └── sources-debian9.list │ ├── base-arm/ │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ ├── rootfs/ │ │ │ └── entrypoint.go │ │ ├── sources-debian10.list │ │ ├── sources-debian11.list │ │ ├── sources-debian12.list │ │ ├── sources-debian8.list │ │ └── sources-debian9.list │ ├── darwin/ │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── darwin-arm64/ │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── llvm-apple/ │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ ├── lcxx.patch │ │ ├── sources-debian10.list │ │ ├── sources-debian11.list │ │ └── sources-debian12.list │ ├── main/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── mips/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── mips32/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── npcap/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── lib/ │ │ └── .gitkeep │ ├── ppc/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ ├── s390x/ │ │ ├── .dockerignore │ │ ├── Dockerfile.tmpl │ │ ├── Makefile │ │ └── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ └── windows-arm64/ │ ├── Dockerfile.tmpl │ ├── Makefile │ ├── rootfs/ │ │ ├── compilers.yaml │ │ └── helloWorld.c │ └── scripts/ │ ├── install-llvm-mingw64.sh │ └── setup-llvm-mingw64.sh └── template.go
SYMBOL INDEX (30 symbols across 14 files)
FILE: go/arm/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/armel/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/armhf/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/base-arm/rootfs/entrypoint.go
function init (line 35) | func init() {
function main (line 44) | func main() {
function doBuild (line 57) | func doBuild(_ *cobra.Command, _ []string) error {
function isDirEmpty (line 72) | func isDirEmpty(name string) (bool, error) {
function buildEnvironment (line 86) | func buildEnvironment(platform string) (map[string]string, error) {
type Compilers (line 118) | type Compilers struct
function loadCompilerSettings (line 126) | func loadCompilerSettings(goos, arch string, env map[string]string) error {
function execBuildCommand (line 157) | func execBuildCommand(env map[string]string) error {
FILE: go/base/rootfs/entrypoint.go
function init (line 35) | func init() {
function main (line 44) | func main() {
function doBuild (line 57) | func doBuild(_ *cobra.Command, _ []string) error {
function isDirEmpty (line 72) | func isDirEmpty(name string) (bool, error) {
function buildEnvironment (line 86) | func buildEnvironment(platform string) (map[string]string, error) {
type Compilers (line 118) | type Compilers struct
function loadCompilerSettings (line 126) | func loadCompilerSettings(goos, arch string, env map[string]string) error {
function execBuildCommand (line 157) | func execBuildCommand(env map[string]string) error {
FILE: go/darwin-arm64/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/darwin/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/main/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/mips/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/mips32/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/ppc/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/s390x/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: go/windows-arm64/rootfs/helloWorld.c
function main (line 2) | int main() {
FILE: template.go
function init (line 44) | func init() {
function main (line 53) | func main() {
function envVars (line 80) | func envVars() map[string]string {
Condensed preview — 132 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (186K chars).
[
{
"path": ".buildkite/fpm-pipeline.yml",
"chars": 1909,
"preview": "# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json\n\nenv:\n IMA"
},
{
"path": ".buildkite/hooks/pre-command",
"chars": 327,
"preview": "#!/bin/bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nif [[ \"$BUILDKITE_PIPELINE_SLUG\" == \"golang-crossbu"
},
{
"path": ".buildkite/hooks/pre-exit",
"chars": 161,
"preview": "#!/bin/bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nunset_secrets\n\n# Ensure that any temporal files cre"
},
{
"path": ".buildkite/llvm-apple-pipeline.yml",
"chars": 3212,
"preview": "# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json\n\nenv:\n IMA"
},
{
"path": ".buildkite/pipeline.yml",
"chars": 9575,
"preview": "# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json\n\nenv:\n SET"
},
{
"path": ".buildkite/pull-requests.json",
"chars": 921,
"preview": "{\n \"jobs\": [\n {\n \"enabled\": true,\n \"pipelineSlug\": \"golang-crossbuild\",\n \"all"
},
{
"path": ".buildkite/scripts/build.sh",
"chars": 586,
"preview": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nMAKEFILE=${1}\n\ncheck_is_arm\n\nadd_bin_path\nw"
},
{
"path": ".buildkite/scripts/buildx.sh",
"chars": 631,
"preview": "#!/usr/bin/env bash\nset -e\nset +x\n\nBUILDPLATFORM=${BUILDPLATFORM:-\"linux/amd64,linux/arm64\"}\n\nBUILDER_NAME=\"multibuilder"
},
{
"path": ".buildkite/scripts/common.sh",
"chars": 2800,
"preview": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nREPO=\"golang-crossbuild\"\nWORKSPACE=\"$(pwd)\"\nBIN=\"${WORKSPACE}/bin\"\nHW_TYPE=\"$(un"
},
{
"path": ".buildkite/scripts/llvm-apple/build.sh",
"chars": 893,
"preview": "#!/usr/bin/env bash\n# This script builds the Docker images but does not push them to a registry.\n# Env variables:\n# - RE"
},
{
"path": ".buildkite/scripts/llvm-apple/publish.sh",
"chars": 528,
"preview": "#!/usr/bin/env bash\n# Env variables:\n# - RELEASE: If set, indicates that this is a production release and images should "
},
{
"path": ".buildkite/scripts/llvm-fpm/build_and_publish.sh",
"chars": 323,
"preview": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nmakefile=${1}\n\nadd_bin_path\nwith_go \"${GOLA"
},
{
"path": ".buildkite/scripts/post-release.sh",
"chars": 924,
"preview": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nTAG=\"v$1\"\nTAG_EXISTS=$(tag_Exists ${TAG})\n\n"
},
{
"path": ".buildkite/scripts/publish.sh",
"chars": 170,
"preview": "#!/usr/bin/env bash\n\nset -euo pipefail\n\nsource .buildkite/scripts/common.sh\n\nMAKEFILE=${1}\n\ncheck_is_arm\nadd_bin_path\nre"
},
{
"path": ".buildkite/scripts/validate-go-version.sh",
"chars": 393,
"preview": "#!/usr/bin/env bash\n\nset -euo pipefail\n\ngo_version=$(cat .go-version)\nif grep -q \"VERSION\\s*:=\\s*${go_version}\" go/Makef"
},
{
"path": ".editorconfig",
"chars": 269,
"preview": "# See: http://editorconfig.org\nroot = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\ntrim_traili"
},
{
"path": ".github/CODEOWNERS",
"chars": 180,
"preview": "* @elastic/elastic-agent-control-plane\n\n# Ownership of CI or related files by the Ingest Eng Prod team\n/.buildkite @elas"
},
{
"path": ".github/actions/bump-golang/action.yml",
"chars": 1595,
"preview": "---\nname: common build tasks\ninputs:\n branch:\n description: 'What branch'\n required: true\n go-minor:\n descrip"
},
{
"path": ".github/dependabot.yml",
"chars": 551,
"preview": "---\nversion: 2\nupdates:\n\n # GitHub actions\n - package-ecosystem: \"github-actions\"\n directory: \"/\"\n schedule:\n "
},
{
"path": ".github/release-drafter.yml",
"chars": 4897,
"preview": "name-template: 'v$RESOLVED_VERSION 🌈'\ntag-template: 'v$RESOLVED_VERSION'\ncategories:\n - title: '🚀 Features'\n labels:"
},
{
"path": ".github/updatecli.d/bump-go-version.sh",
"chars": 4120,
"preview": "#!/usr/bin/env bash\n#\n# Given the Microsoft Golang release version this script will bump the version.\n#\n# This script is"
},
{
"path": ".github/updatecli.d/bump-golang.yml",
"chars": 3214,
"preview": "---\nname: Bump golang-version to latest version\npipelineid: 'bump-golang-version-{{ requiredEnv \"BRANCH\" }}'\n\nscms:\n gi"
},
{
"path": ".github/workflows/bump-golang-previous.yml",
"chars": 707,
"preview": "---\nname: bump-golang-previous\n\non:\n workflow_dispatch:\n schedule:\n - cron: '0 4 * * 1-6'\n\npermissions:\n contents:"
},
{
"path": ".github/workflows/bump-golang.yml",
"chars": 618,
"preview": "---\nname: bump-golang-main\n\non:\n workflow_dispatch:\n schedule:\n - cron: '0 3 * * 1-6'\n\npermissions:\n contents: rea"
},
{
"path": ".github/workflows/catalog-info.yml",
"chars": 356,
"preview": "---\nname: catalog-info\n\non:\n pull_request:\n branches:\n - main\n paths:\n - 'catalog-info.yaml'\n\npermissio"
},
{
"path": ".github/workflows/release-drafter.yml",
"chars": 786,
"preview": "name: Release Drafter\n\non:\n push:\n tags:\n - v*.*\n\npermissions:\n contents: read\n\njobs:\n update_release_draft:\n"
},
{
"path": ".gitignore",
"chars": 88,
"preview": "*.iml\n*.swp\n*.o\n.idea\n.vagrant\n.vscode\n_obj\nDockerfile\n.status.*\n*.bck\nnpcap/lib/*.exe\n\n"
},
{
"path": ".go-version",
"chars": 6,
"preview": "1.26.2"
},
{
"path": ".mergify.yml",
"chars": 6138,
"preview": "queue_rules:\n - name: default\n merge_method: squash\n conditions:\n - check-success=buildkite/golang-crossbuil"
},
{
"path": ".updatecli-version",
"chars": 8,
"preview": "v0.109.0"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "Makefile",
"chars": 1968,
"preview": "include Makefile.common\n\nTARGETS=go\nARM_TARGETS=go\n\n\nbuild: status=\".status.build\"\nbuild:\n\t@echo '0' > ${status}\n\t@$(for"
},
{
"path": "Makefile.common",
"chars": 1284,
"preview": "REPOSITORY ?= docker.elastic.co/beats-dev\nVCS_REF := $(shell git rev-parse HEAD)\nVCS_URL := https://githu"
},
{
"path": "NPCAP.md",
"chars": 2086,
"preview": "# NPCAP\n\nIf you'd like to bump the npcap version please follow the below steps:\n\n1) Update `NPCAP_VERSION` value in the "
},
{
"path": "README.md",
"chars": 20910,
"preview": "| | main | 1.25 |\n|-------------------|------|-|\n| golang-crossbuild |[/$(NAME):$(VERSION"
},
{
"path": "fpm/rootfs/entrypoint.sh",
"chars": 200,
"preview": "#!/usr/bin/env sh\n\nif [ -z ${EXEC_UID+x} ] || [ -z ${EXEC_GID+x} ]; then\n exec \"$@\"\nfi\n\ngroupadd -f -g \"$EXEC_GID\" fpm\n"
},
{
"path": "go/Makefile",
"chars": 49,
"preview": "include ./Makefile.debian9\n\nTAG_EXTENSION := \"\"\n"
},
{
"path": "go/Makefile.common",
"chars": 1765,
"preview": "SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))\ninclude $(SELF_DIR)/../Makefile.common\n\nNAME := golang-crossbu"
},
{
"path": "go/Makefile.debian10",
"chars": 565,
"preview": "IMAGES := base main darwin armhf npcap\nARM_IMAGES := base-arm darwin-arm64\nDEBIAN_VERSION := 10\nTAG_EXTENSIO"
},
{
"path": "go/Makefile.debian11",
"chars": 565,
"preview": "IMAGES := base main darwin armhf npcap\nARM_IMAGES := base-arm darwin-arm64\nDEBIAN_VERSION := 11\nTAG_EXTENSIO"
},
{
"path": "go/Makefile.debian12",
"chars": 600,
"preview": "IMAGES := base main darwin armhf armel mips ppc s390x npcap\nARM_IMAGES := base-arm darwin-arm64 windows-arm6"
},
{
"path": "go/Makefile.debian7",
"chars": 323,
"preview": "IMAGES := base main\nDEBIAN_VERSION := 7\nTAG_EXTENSION := -debian7\n\nexport DEBIAN_VERSION TAG_EXTENSION\n\nbuild:\n"
},
{
"path": "go/Makefile.debian8",
"chars": 572,
"preview": "IMAGES := base main darwin npcap\nARM_IMAGES := base-arm\nDEBIAN_VERSION := 8\nTAG_EXTENSION := -debian8\n\nexpo"
},
{
"path": "go/Makefile.debian9",
"chars": 550,
"preview": "IMAGES := base main darwin armhf npcap\nARM_IMAGES := base-arm\nDEBIAN_VERSION := 9\nTAG_EXTENSION := -debian9"
},
{
"path": "go/arm/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/arm/Dockerfile.tmpl",
"chars": 3415,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM --platform=linux/amd64 ${REPOSIT"
},
{
"path": "go/arm/Makefile",
"chars": 519,
"preview": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush"
},
{
"path": "go/arm/rootfs/compilers.yaml",
"chars": 83,
"preview": "---\n\nlinux:\n arm64:\n CC: aarch64-linux-gnu-gcc\n CXX: aarch64-linux-gnu-g++\n"
},
{
"path": "go/arm/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/armel/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/armel/Dockerfile.tmpl",
"chars": 2051,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:"
},
{
"path": "go/armel/Makefile",
"chars": 27,
"preview": "include ../Makefile.common\n"
},
{
"path": "go/armel/rootfs/compilers.yaml",
"chars": 263,
"preview": "---\n\nlinux:\n armv6:\n # Using debian armel for ARMv6.\n # This is the same as ARMv5 so it will use softfp instead o"
},
{
"path": "go/armel/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/armhf/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/armhf/Dockerfile.tmpl",
"chars": 2061,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:"
},
{
"path": "go/armhf/Makefile",
"chars": 27,
"preview": "include ../Makefile.common\n"
},
{
"path": "go/armhf/rootfs/compilers.yaml",
"chars": 87,
"preview": "---\n\nlinux:\n armv7:\n CC: arm-linux-gnueabihf-gcc\n CXX: arm-linux-gnueabihf-g++\n"
},
{
"path": "go/armhf/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/base/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/base/Dockerfile.tmpl",
"chars": 3073,
"preview": "ARG DEBIAN_VERSION=9\nFROM debian:${DEBIAN_VERSION}\n\nARG DEBIAN_VERSION\n# Replace sources.list in order to use archive.de"
},
{
"path": "go/base/Makefile",
"chars": 519,
"preview": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush"
},
{
"path": "go/base/rootfs/entrypoint.go",
"chars": 4028,
"preview": "// +build linux\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.c"
},
{
"path": "go/base/sources-debian10.list",
"chars": 161,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb http://archive.debian.org/debian buster main\ndeb http://archive.debian"
},
{
"path": "go/base/sources-debian11.list",
"chars": 214,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb http://deb.debian.org/debian bullseye main\ndeb http://deb.debian.org/d"
},
{
"path": "go/base/sources-debian12.list",
"chars": 159,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb http://deb.debian.org/debian bookworm main\ndeb http://deb.debian.org/d"
},
{
"path": "go/base/sources-debian7.list",
"chars": 210,
"preview": "# see https://wiki.debian.org/CrossToolchains\n# https://bugs.launchpad.net/torios/+bug/1835529\ndeb http://archive.debian"
},
{
"path": "go/base/sources-debian8.list",
"chars": 210,
"preview": "# see https://wiki.debian.org/CrossToolchains\n# https://bugs.launchpad.net/torios/+bug/1835529\ndeb http://archive.debian"
},
{
"path": "go/base/sources-debian9.list",
"chars": 163,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb http://archive.debian.org/debian stretch main\ndeb http://archive.debia"
},
{
"path": "go/base-arm/Dockerfile.tmpl",
"chars": 3891,
"preview": "ARG DEBIAN_VERSION=9\nFROM arm64v8/debian:${DEBIAN_VERSION}\n\nARG DEBIAN_VERSION\n# Replace sources.list in order to use ar"
},
{
"path": "go/base-arm/Makefile",
"chars": 27,
"preview": "include ../Makefile.common\n"
},
{
"path": "go/base-arm/rootfs/entrypoint.go",
"chars": 4028,
"preview": "// +build linux\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"os/exec\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.c"
},
{
"path": "go/base-arm/sources-debian10.list",
"chars": 187,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb [arch=arm64] http://archive.debian.org/debian buster main\ndeb [arch=ar"
},
{
"path": "go/base-arm/sources-debian11.list",
"chars": 253,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb [arch=arm64] http://deb.debian.org/debian bullseye main\ndeb [arch=arm6"
},
{
"path": "go/base-arm/sources-debian12.list",
"chars": 185,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb [arch=arm64] http://deb.debian.org/debian bookworm main\ndeb [arch=arm6"
},
{
"path": "go/base-arm/sources-debian8.list",
"chars": 62,
"preview": "deb [arch=arm64] http://archive.debian.org/debian jessie main\n"
},
{
"path": "go/base-arm/sources-debian9.list",
"chars": 143,
"preview": "deb [arch=arm64] http://archive.debian.org/debian stretch main\ndeb [arch=arm64] http://archive.debian.org/debian-securit"
},
{
"path": "go/darwin/Dockerfile.tmpl",
"chars": 3331,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\n\n{{- if or (eq .DEBIAN_VERSION \"10\") "
},
{
"path": "go/darwin/Makefile",
"chars": 269,
"preview": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush"
},
{
"path": "go/darwin/rootfs/compilers.yaml",
"chars": 62,
"preview": "---\n\ndarwin:\n amd64:\n CC: o64-clang\n CXX: o64-clang++\n"
},
{
"path": "go/darwin/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/darwin-arm64/Dockerfile.tmpl",
"chars": 2389,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\n{{- if or (eq .DEBIAN_VERSION \"10\") ("
},
{
"path": "go/darwin-arm64/Makefile",
"chars": 269,
"preview": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush"
},
{
"path": "go/darwin-arm64/rootfs/compilers.yaml",
"chars": 64,
"preview": "---\n\ndarwin:\n arm64:\n CC: oa64-clang\n CXX: oa64-clang++\n"
},
{
"path": "go/darwin-arm64/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/llvm-apple/Dockerfile.tmpl",
"chars": 3550,
"preview": "ARG DEBIAN_VERSION=9\nFROM debian:${DEBIAN_VERSION} AS BUILD_LLVM_APPLE\n\nARG DEBIAN_VERSION\n# Replace sources.list in ord"
},
{
"path": "go/llvm-apple/Makefile",
"chars": 917,
"preview": "include ../Makefile.common\n\nSUFFIX := $(shell basename $(CURDIR))\nTAG \t\t := $(REPOSITORY)/$(NAME):$(SUFFIX)$(T"
},
{
"path": "go/llvm-apple/lcxx.patch",
"chars": 539,
"preview": "diff --git a/wrapper/target.cpp b/wrapper/target.cpp\nindex 82bf65c..a2520e2 100644\n--- a/wrapper/target.cpp\n+++ b/wrappe"
},
{
"path": "go/llvm-apple/sources-debian10.list",
"chars": 161,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb http://archive.debian.org/debian buster main\ndeb http://archive.debian"
},
{
"path": "go/llvm-apple/sources-debian11.list",
"chars": 214,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb http://deb.debian.org/debian bullseye main\ndeb http://deb.debian.org/d"
},
{
"path": "go/llvm-apple/sources-debian12.list",
"chars": 159,
"preview": "# see https://wiki.debian.org/CrossToolchains\ndeb http://deb.debian.org/debian bookworm main\ndeb http://deb.debian.org/d"
},
{
"path": "go/main/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/main/Dockerfile.tmpl",
"chars": 2674,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:"
},
{
"path": "go/main/Makefile",
"chars": 27,
"preview": "include ../Makefile.common\n"
},
{
"path": "go/main/rootfs/compilers.yaml",
"chars": 335,
"preview": "---\n\nwindows:\n 386:\n CC: i686-w64-mingw32-gcc\n CXX: i686-w64-mingw32-g++\n amd64:\n CC: x86_64-w64-mingw32-gc"
},
{
"path": "go/main/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/mips/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/mips/Dockerfile.tmpl",
"chars": 3157,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:"
},
{
"path": "go/mips/Makefile",
"chars": 27,
"preview": "include ../Makefile.common\n"
},
{
"path": "go/mips/rootfs/compilers.yaml",
"chars": 178,
"preview": "---\n\nlinux:\n mips64le:\n CC: mips64el-linux-gnuabi64-gcc\n CXX: mips64el-linux-gnuabi64-g++\n mips64:\n CC: mip"
},
{
"path": "go/mips/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/mips32/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/mips32/Dockerfile.tmpl",
"chars": 2931,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:"
},
{
"path": "go/mips32/Makefile",
"chars": 27,
"preview": "include ../Makefile.common\n"
},
{
"path": "go/mips32/rootfs/compilers.yaml",
"chars": 146,
"preview": "---\n\nlinux:\n mips:\n CC: mips-linux-gnu-gcc\n CXX: mips-linux-gnu-g++\n mipsle:\n CC: mipsel-linux-gnu-gcc\n "
},
{
"path": "go/mips32/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/npcap/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/npcap/Dockerfile.tmpl",
"chars": 514,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:"
},
{
"path": "go/npcap/Makefile",
"chars": 231,
"preview": "include ../Makefile.common\n\nSUFFIX = $(SUFFIX_NPCAP_VERSION)\n\npush:\n\t@[ \"$(REPOSITORY)\" = \"$(NPCAP_REPOSITORY)\" ] \\\n\t&& "
},
{
"path": "go/npcap/lib/.gitkeep",
"chars": 0,
"preview": ""
},
{
"path": "go/ppc/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/ppc/Dockerfile.tmpl",
"chars": 2638,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:"
},
{
"path": "go/ppc/Makefile",
"chars": 27,
"preview": "include ../Makefile.common\n"
},
{
"path": "go/ppc/rootfs/compilers.yaml",
"chars": 168,
"preview": "---\n\nlinux:\n ppc64:\n CC: powerpc64-linux-gnu-gcc\n CXX: powerpc64-linux-gnu-g++\n ppc64le:\n CC: powerpc64le-l"
},
{
"path": "go/ppc/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/s390x/.dockerignore",
"chars": 9,
"preview": "Makefile\n"
},
{
"path": "go/s390x/Dockerfile.tmpl",
"chars": 2154,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\nFROM ${REPOSITORY}/golang-crossbuild:"
},
{
"path": "go/s390x/Makefile",
"chars": 27,
"preview": "include ../Makefile.common\n"
},
{
"path": "go/s390x/rootfs/compilers.yaml",
"chars": 79,
"preview": "---\n\nlinux:\n s390x:\n CC: s390x-linux-gnu-gcc\n CXX: s390x-linux-gnu-g++\n"
},
{
"path": "go/s390x/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/windows-arm64/Dockerfile.tmpl",
"chars": 2162,
"preview": "ARG REPOSITORY=docker.elastic.co/beats-dev\nARG VERSION=1.26.2\nARG TAG_EXTENSION=''\n\nFROM ${REPOSITORY}/golang-crossbuild"
},
{
"path": "go/windows-arm64/Makefile",
"chars": 269,
"preview": "include ../Makefile.common\n\nifeq ($(DOCKER_MULTIARCH),1)\nDOCKER_CMD := $(SELF_DIR)/../.buildkite/scripts/buildx.sh\n\npush"
},
{
"path": "go/windows-arm64/rootfs/compilers.yaml",
"chars": 90,
"preview": "---\n\nwindows:\n arm64:\n CC: aarch64-w64-mingw32-gcc\n CXX: aarch64-w64-mingw32-g++\n\n"
},
{
"path": "go/windows-arm64/rootfs/helloWorld.c",
"chars": 75,
"preview": "#include <stdio.h>\nint main() {\n printf(\"Hello, World!\");\n return 0;\n}\n"
},
{
"path": "go/windows-arm64/scripts/install-llvm-mingw64.sh",
"chars": 1677,
"preview": "#!/usr/bin/env bash\n#\n# Copied from: https://github.com/x1unix/docker-go-mingw/tree/20dfaff6efe8fe3a4ff588a58ccb31646cd2"
},
{
"path": "go/windows-arm64/scripts/setup-llvm-mingw64.sh",
"chars": 2271,
"preview": "#!/usr/bin/env bash\n#\n# Copied from: https://github.com/x1unix/docker-go-mingw/tree/20dfaff6efe8fe3a4ff588a58ccb31646cd2"
},
{
"path": "template.go",
"chars": 2092,
"preview": "// Licensed to Elasticsearch B.V. under one or more contributor\n// license agreements. See the NOTICE file distributed w"
}
]
About this extraction
This page contains the full source code of the elastic/golang-crossbuild GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 132 files (166.4 KB), approximately 52.7k tokens, and a symbol index with 30 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.