Skip to content

Commit bb1e666

Browse files
fix: adjust changes for make
1 parent 7742c90 commit bb1e666

File tree

7 files changed

+38
-2384
lines changed

7 files changed

+38
-2384
lines changed

.buildkite/pipeline.package.mbp.yml

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,6 @@ steps:
4747
plugins:
4848
- *oidc_plugin
4949

50-
<<<<<<< HEAD
51-
=======
52-
- label: "Package FIPS x86_64 snapshot"
53-
if: "build.env('VERSION_QUALIFIER') == null"
54-
key: "package-fips-x86-64-snapshot"
55-
command: ".buildkite/scripts/package.sh snapshot"
56-
env:
57-
FIPS: "true"
58-
agents:
59-
provider: "gcp"
60-
image: "${IMAGE_UBUNTU_X86_64}"
61-
machineType: "c2-standard-16"
62-
artifact_paths:
63-
- build/distributions/**
64-
plugins:
65-
- *oidc_plugin
66-
67-
- label: "Package FIPS x86_64 staging"
68-
key: "package-fips-x86-64-staging"
69-
command: |
70-
source .buildkite/scripts/version_qualifier.sh
71-
.buildkite/scripts/package.sh staging
72-
env:
73-
FIPS: "true"
74-
agents:
75-
provider: "gcp"
76-
image: "${IMAGE_UBUNTU_X86_64}"
77-
machineType: "c2-standard-16"
78-
artifact_paths:
79-
- build/distributions/**
80-
plugins:
81-
- *oidc_plugin
82-
83-
>>>>>>> 7da3f69 (fix: package fleet-server using golang-crossbuild (#5392))
8450
- label: "Package aarch64 snapshot"
8551
if: "build.env('VERSION_QUALIFIER') == null"
8652
key: "package-arm-snapshot"
@@ -108,40 +74,6 @@ steps:
10874
plugins:
10975
- *oidc_plugin
11076

111-
<<<<<<< HEAD
112-
=======
113-
- label: "Package FIPS aarch64 snapshot"
114-
if: "build.env('VERSION_QUALIFIER') == null"
115-
key: "package-fips-arm-snapshot"
116-
command: ".buildkite/scripts/package.sh snapshot"
117-
env:
118-
FIPS: "true"
119-
agents:
120-
provider: "aws"
121-
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
122-
instanceType: "t4g.2xlarge"
123-
artifact_paths:
124-
- build/distributions/**
125-
plugins:
126-
- *oidc_plugin
127-
128-
- label: "Package FIPS aarch64 staging"
129-
key: "package-fips-arm-staging"
130-
command: |
131-
source .buildkite/scripts/version_qualifier.sh
132-
.buildkite/scripts/package.sh staging
133-
env:
134-
FIPS: "true"
135-
agents:
136-
provider: "aws"
137-
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
138-
instanceType: "t4g.2xlarge"
139-
artifact_paths:
140-
- build/distributions/**
141-
plugins:
142-
- *oidc_plugin
143-
144-
>>>>>>> 7da3f69 (fix: package fleet-server using golang-crossbuild (#5392))
14577
- label: "DRA snapshot"
14678
if: "${FILE_EXISTS_IN_REPO} && build.env('VERSION_QUALIFIER') == null"
14779
key: "dra-snapshot"

.buildkite/pipeline.yml

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,19 @@ env:
99
DOCKER_IMAGE_GIT_TAG: "${BUILDKITE_BRANCH}" # needs to rename for rollback
1010
GO_AGENT_IMAGE: "golang:${GO_VERSION}"
1111
TERRAFORM_VERSION: "1.6.4"
12-
<<<<<<< HEAD
13-
=======
1412
IMAGE_UBUNTU_X86_64: "family/core-ubuntu-2204"
1513
IMAGE_UBUNTU_ARM_64: "core-ubuntu-2204-aarch64"
16-
IMAGE_UBUNTU_X86_64_FIPS: "platform-ingest-fleet-server-ubuntu-2204-fips"
1714

1815
# This section is used to define the plugins that will be used in the pipeline.
1916
# See https://buildkite.com/docs/pipelines/integrations/plugins/using#using-yaml-anchors-with-plugins
2017
common:
21-
- test_collector_plugin: &test_collector_plugin
22-
test-collector#v1.11.0:
23-
files: "build/test-*.xml"
24-
format: "junit"
25-
branches: "main"
26-
debug: true
27-
- bk_analytics_token_plugin: &bk_analytics_token_plugin
28-
elastic/vault-secrets#v0.1.0:
29-
path: "kv/ci-shared/platform-ingest/buildkite_analytics_token"
30-
field: "token"
31-
env_var: "BUILDKITE_ANALYTICS_TOKEN"
32-
- docker_elastic_login_plugin: &docker_elastic_login_plugin
33-
elastic/vault-docker-login#v0.6.0:
34-
secret_path: 'kv/ci-shared/platform-ingest/elastic_docker_registry'
3518
# See https://github.com/elastic/oblt-infra/blob/main/conf/resources/repos/fleet-server/01-gcp-buildkite-oidc.tf
3619
# This plugin authenticates to Google Cloud using the OIDC token.
3720
- oidc_plugin: &oidc_plugin
3821
elastic/oblt-google-auth#v1.2.0:
3922
lifetime: 10800 # seconds
4023
project-id: "elastic-observability-ci"
4124
project-number: "911195782929"
42-
>>>>>>> 7da3f69 (fix: package fleet-server using golang-crossbuild (#5392))
4325

4426
steps:
4527
- group: "Check and build"
@@ -53,35 +35,10 @@ steps:
5335
cpu: "8"
5436
memory: "4G"
5537

56-
<<<<<<< HEAD
57-
- label: ":building_construction: Run local build"
58-
key: make-local
59-
command: "make local"
60-
agents:
61-
image: "${GO_AGENT_IMAGE}"
62-
cpu: "8"
63-
memory: "4G"
64-
=======
6538
- label: "Package x86_64"
6639
key: "package-x86-64-pr"
6740
env:
68-
PLATFORMS: "linux/amd64,darwin/amd64,windows/amd64"
69-
command: ".buildkite/scripts/release_test.sh"
70-
artifact_paths:
71-
- build/distributions/**
72-
agents:
73-
provider: "gcp"
74-
image: "${IMAGE_UBUNTU_X86_64}"
75-
machineType: "c2-standard-16"
76-
plugins:
77-
- *oidc_plugin
78-
>>>>>>> 7da3f69 (fix: package fleet-server using golang-crossbuild (#5392))
79-
80-
- label: "Package x86_64 FIPS"
81-
key: "package-fips-x86-64-pr"
82-
env:
83-
FIPS: "true"
84-
PLATFORMS: "linux/amd64"
41+
PLATFORMS: "linux/amd64 darwin/amd64 windows/amd64"
8542
command: ".buildkite/scripts/release_test.sh"
8643
artifact_paths:
8744
- build/distributions/**
@@ -95,22 +52,7 @@ steps:
9552
- label: "Package aarch64"
9653
key: "package-arm64-pr"
9754
env:
98-
PLATFORMS: "linux/arm64,darwin/arm64"
99-
command: ".buildkite/scripts/release_test.sh"
100-
artifact_paths:
101-
- build/distributions/**
102-
agents:
103-
provider: "aws"
104-
imagePrefix: "${IMAGE_UBUNTU_ARM_64}"
105-
instanceType: "t4g.2xlarge"
106-
plugins:
107-
- *oidc_plugin
108-
109-
- label: "Package aarch64 FIPS"
110-
key: "package-fips-arm64-pr"
111-
env:
112-
FIPS: "true"
113-
PLATFORMS: "linux/arm64"
55+
PLATFORMS: "linux/arm64 darwin/arm64"
11456
command: ".buildkite/scripts/release_test.sh"
11557
artifact_paths:
11658
- build/distributions/**

.buildkite/scripts/package.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,10 @@ with_mage
2727
case "${TYPE}" in
2828
"snapshot")
2929
export SNAPSHOT=true
30-
<<<<<<< HEAD
31-
make release
30+
make docker-release
3231
;;
3332
"staging")
34-
make release
35-
=======
36-
mage docker:release
37-
;;
38-
"staging")
39-
mage docker:release
40-
>>>>>>> 7da3f69 (fix: package fleet-server using golang-crossbuild (#5392))
33+
make docker-release
4134
;;
4235
*)
4336
echo "The option is unsupported yet"

.buildkite/scripts/test-release.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@
33
set -euo pipefail
44

55
FLEET_SERVER_VERSION=${1:?"Fleet Server version is needed"}
6+
PLATFORMS=${PLATFORMS:-"darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64"}
67

7-
PLATFORM_FILES=(darwin-aarch64.tar.gz darwin-x86_64.tar.gz linux-arm64.tar.gz linux-x86_64.tar.gz windows-x86_64.zip)
8-
if [ "$FIPS" = "true" ] ; then
9-
PLATFORM_FILES=(linux-arm64-fips.tar.gz linux-x86_64-fips.tar.gz)
10-
fi
8+
PLATFORM_FILES=()
9+
for p in $PLATFORMS; do
10+
os="${p%%/*}"
11+
arch="${p##*/}"
12+
13+
case "$os/$arch" in
14+
darwin/arm64) arch="aarch64" ;;
15+
*/amd64) arch="x86_64" ;;
16+
esac
17+
18+
case "$os" in
19+
windows) ext="zip" ;;
20+
*) ext="tar.gz" ;;
21+
esac
22+
23+
file="${os}-${arch}.${ext}"
24+
PLATFORM_FILES+=("$file")
25+
done
1126

1227
#make release
1328

@@ -23,17 +38,17 @@ for PLATFORM_FILE in "${PLATFORM_FILES[@]}"
2338
do
2439
file="${FILE_PREFIX}${PLATFORM_FILE}"
2540
if [ ! -f "${file}" ]; then
26-
echo -e "${RED}!! ${PLATFORM_FILE}: The file was not created.${NO_COLOR}"
41+
echo -e "${RED}!! ${file}: The file was not created.${NO_COLOR}"
2742
exit 1
2843
else
29-
echo -e "- ${PLATFORM_FILE} ${GREEN}OK${NO_COLOR}"
44+
echo -e "- ${file} ${GREEN}OK${NO_COLOR}"
3045
fi
3146

3247
fileSha512="${file}.sha512"
3348
if [ ! -f "${fileSha512}" ]; then
3449
echo -e "${RED}!! ${fileSha512}: The file was not created.${NO_COLOR}"
3550
exit 1
3651
else
37-
echo -e "- ${PLATFORM_FILE}.sha512 ${GREEN}OK${NO_COLOR}"
52+
echo -e "- ${file}.sha512 ${GREEN}OK${NO_COLOR}"
3853
fi
3954
done

Dockerfile.fips

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,7 @@ RUN go mod download && go mod verify
1616
ENTRYPOINT [ "make" ]
1717
CMD [ "release" ]
1818

19-
<<<<<<< HEAD
2019
FROM base AS builder
21-
=======
22-
# FIPS docker image defined below
23-
# Does not use base as the lowest layer so we don't have to deal with user/ownership issues when building the image.
24-
ARG GO_VERSION
25-
# Suffix should be main-debian11-fips or base-arm-debian11-fips
26-
ARG SUFFIX
27-
FROM docker.elastic.co/beats-dev/golang-crossbuild:${GO_VERSION}-${SUFFIX} AS builder
28-
29-
WORKDIR /fleet-server
30-
ENV PATH="$PATH:/go/bin"
31-
COPY go.mod go.sum ./
32-
RUN go mod download && go mod verify
33-
RUN go install github.com/magefile/mage # uses version in go.mod
34-
>>>>>>> 7da3f69 (fix: package fleet-server using golang-crossbuild (#5392))
3520

3621
COPY . .
3722

Makefile

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ DEFAULT_VERSION=$(shell awk '/const DefaultVersion/{print $$NF}' version/version
1212
TARGET_ARCH_amd64=x86_64
1313
TARGET_ARCH_arm64=arm64
1414
PLATFORMS ?= darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64
15-
BUILDMODE_linux_amd64=-buildmode=pie
16-
BUILDMODE_linux_arm64=-buildmode=pie
17-
BUILDMODE_windows_amd64=-buildmode=pie
18-
BUILDMODE_darwin_amd64=-buildmode=pie
19-
BUILDMODE_darwin_arm64=-buildmode=pie
2015

2116
CROSSBUILD_SUFFIX=main-debian11
2217
CROSSBUILD_ARM_SUFFIX=base-arm-debian9
@@ -65,6 +60,10 @@ ifeq "${FIPS}" "true"
6560
DOCKER_IMAGE_TAG:=${DOCKER_IMAGE_TAG}-fips
6661
endif
6762
endif
63+
CGO_ENABLED?=0
64+
ifeq "${FIPS}" "true"
65+
CGO_ENABLED=1
66+
endif
6867
DOCKER_IMAGE?=docker.elastic.co/fleet-server/fleet-server
6968

7069
PLATFORM_TARGETS=$(addprefix release-, $(PLATFORMS))
@@ -138,7 +137,7 @@ list-platforms: ## - Show the possible PLATFORMS
138137
.PHONY: local
139138
local: ## - Build local binary for local environment (bin/fleet-server)
140139
@printf "${CMD_COLOR_ON} Build binaries using local go installation\n${CMD_COLOR_OFF}"
141-
${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" -o ./bin/fleet-server .
140+
CGO_ENABLED=${CGO_ENABLED} ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" -o ./bin/fleet-server .
142141
@printf "${CMD_COLOR_ON} Binaries in ./bin/\n${CMD_COLOR_OFF}"
143142

144143
.PHONY: $(COVER_TARGETS)
@@ -147,8 +146,7 @@ $(COVER_TARGETS): cover-%: ## - Build a binary with the -cover flag for integrat
147146
$(eval $@_OS := $(firstword $(subst /, ,$(lastword $(subst cover-, ,$@)))))
148147
$(eval $@_GO_ARCH := $(lastword $(subst /, ,$(lastword $(subst cover-, ,$@)))))
149148
$(eval $@_ARCH := $(TARGET_ARCH_$($@_GO_ARCH)))
150-
$(eval $@_BUILDMODE:= $(BUILDMODE_$($@_OS)_$($@_GO_ARCH)))
151-
GOOS=$($@_OS) GOARCH=$($@_GO_ARCH) ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -cover -coverpkg=./... -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" $($@_BUILDMODE) -o build/cover/fleet-server-$(VERSION)-$($@_OS)-$($@_ARCH)$(FIPSSUFFIX)/fleet-server$(if $(filter windows,$($@_OS)),.exe,) .
149+
CGO_ENABLED=${CGO_ENABLED} GOOS=$($@_OS) GOARCH=$($@_GO_ARCH) ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -cover -coverpkg=./... -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" -o build/cover/fleet-server-$(VERSION)-$($@_OS)-$($@_ARCH)$(FIPSSUFFIX)/fleet-server$(if $(filter windows,$($@_OS)),.exe,) .
152150

153151
.PHONY: clean
154152
clean: ## - Clean up build artifacts
@@ -269,8 +267,7 @@ $(PLATFORM_TARGETS): release-%:
269267
$(eval $@_OS := $(firstword $(subst /, ,$(lastword $(subst release-, ,$@)))))
270268
$(eval $@_GO_ARCH := $(lastword $(subst /, ,$(lastword $(subst release-, ,$@)))))
271269
$(eval $@_ARCH := $(TARGET_ARCH_$($@_GO_ARCH)))
272-
$(eval $@_BUILDMODE:= $(BUILDMODE_$($@_OS)_$($@_GO_ARCH)))
273-
GOOS=$($@_OS) GOARCH=$($@_GO_ARCH) ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" $($@_BUILDMODE) -o build/binaries/fleet-server-$(VERSION)-$($@_OS)-$($@_ARCH)$(FIPSSUFFIX)/fleet-server .
270+
CGO_ENABLED=${CGO_ENABLED} GOOS=$($@_OS) GOARCH=$($@_GO_ARCH) ${GOFIPSEXPERIMENT} go build -tags=${GOBUILDTAGS} -gcflags="${GCFLAGS}" -ldflags="${LDFLAGS}" -o build/binaries/fleet-server-$(VERSION)-$($@_OS)-$($@_ARCH)$(FIPSSUFFIX)/fleet-server .
274271
@$(MAKE) OS=$($@_OS) ARCH=$($@_ARCH) package-target
275272

276273
.PHONY: build-docker
@@ -321,6 +318,8 @@ endif
321318
build-releaser: ## - Build a Docker image to run make package including all build tools
322319
ifeq ($(shell uname -p),arm)
323320
$(eval SUFFIX := ${CROSSBUILD_ARM_SUFFIX})
321+
else ifeq ($(shell uname -p),aarch64)
322+
$(eval SUFFIX := ${CROSSBUILD_ARM_SUFFIX})
324323
else
325324
$(eval SUFFIX := ${CROSSBUILD_SUFFIX})
326325
endif
@@ -332,16 +331,16 @@ endif
332331

333332
.PHONY: docker-release
334333
docker-release: build-releaser ## - Builds a release for all platforms in a dockerised environment
335-
docker run --rm -u $(shell id -u):$(shell id -g) --env=GOCACHE=/go/cache --volume $(PWD):/go/src/github.com/elastic/fleet-server $(BUILDER_IMAGE) release
334+
docker run --rm -u $(shell id -u):$(shell id -g) --env=GOCACHE=/go/cache --env='PLATFORMS=${PLATFORMS}' --volume $(PWD):/go/src/github.com/elastic/fleet-server $(BUILDER_IMAGE) release
336335

337336
.PHONY: docker-cover-e2e-binaries
338337
docker-cover-e2e-binaries: build-releaser
339338
ifeq "${FIPS}" "true"
340339
## non-linux is currently unsupported for FIPS
341-
docker run --rm -u $(shell id -u):$(shell id -g) --env=GOCACHE=/go/cache --volume $(PWD):/go/src/github.com/elastic/fleet-server -e SNAPSHOT=true -e DEV=$(DEV) -e FIPS=$(FIPS) $(BUILDER_IMAGE) cover-linux/$(shell go env GOARCH)
340+
docker run --rm -u $(shell id -u):$(shell id -g) --env=GOCACHE=/go/cache --env='PLATFORMS=${PLATFORMS}' --volume $(PWD):/go/src/github.com/elastic/fleet-server -e SNAPSHOT=true -e DEV=$(DEV) -e FIPS=$(FIPS) $(BUILDER_IMAGE) cover-linux/$(shell go env GOARCH)
342341
else
343342
## Build for local architecture and for linux/$ARCH for docker images.
344-
docker run --rm -u $(shell id -u):$(shell id -g) --env=GOCACHE=/go/cache --volume $(PWD):/go/src/github.com/elastic/fleet-server -e SNAPSHOT=true -e DEV=$(DEV) -e FIPS=$(FIPS) $(BUILDER_IMAGE) cover-linux/$(shell go env GOARCH) cover-$(shell go env GOOS)/$(shell go env GOARCH)
343+
docker run --rm -u $(shell id -u):$(shell id -g) --env=GOCACHE=/go/cache --env='PLATFORMS=${PLATFORMS}' --volume $(PWD):/go/src/github.com/elastic/fleet-server -e SNAPSHOT=true -e DEV=$(DEV) -e FIPS=$(FIPS) $(BUILDER_IMAGE) cover-linux/$(shell go env GOARCH) cover-$(shell go env GOOS)/$(shell go env GOARCH)
345344
endif
346345

347346
.PHONY: release

0 commit comments

Comments
 (0)