Skip to content

Commit e9c8ebb

Browse files
committed
feat: support building a release in a dockerised environment
This will make the build reproducible across machines
1 parent cb956b8 commit e9c8ebb

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.ci
2+
.github
3+
build

Dockerfile.build

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG GO_VERSION
2+
FROM golang:${GO_VERSION}-stretch
3+
4+
RUN apt-get update && apt-get install -y zip
5+
6+
WORKDIR /go/src/github.com/elastic/fleet-server
7+
8+
ENTRYPOINT [ "make", "release" ]

Makefile

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
SHELL=/bin/bash
2+
GO_VERSION=$(shell cat '.go-version')
23
DEFAULT_VERSION=$(shell awk '/const defaultVersion/{print $$NF}' main.go | tr -d '"')
34
TARGET_ARCH_386=x86
45
TARGET_ARCH_amd64=x86_64
@@ -11,6 +12,7 @@ BUILDMODE_windows_amd64=-buildmode=pie
1112
BUILDMODE_darwin_amd64=-buildmode=pie
1213
BUILDMODE_darwin_arm64=-buildmode=pie
1314

15+
BUILDER_IMAGE=docker.elastic.co/observability-ci/fleet-server-builder:latest
1416

1517
ifdef VERSION_QUALIFIER
1618
DEFAULT_VERSION:=${DEFAULT_VERSION}-${VERSION_QUALIFIER}
@@ -140,6 +142,13 @@ else
140142
@cd build/distributions && shasum -a 512 fleet-server-$(VERSION)-$(OS)-$(ARCH).tar.gz > fleet-server-$(VERSION)-$(OS)-$(ARCH).tar.gz.sha512
141143
endif
142144

145+
build-releaser: ## - Build a Docker image to run make package including all build tools
146+
docker build -t $(BUILDER_IMAGE) -f Dockerfile.build --build-arg GO_VERSION=$(GO_VERSION) .
147+
148+
.PHONY: docker-release
149+
docker-release: build-releaser ## - Builds a release for all platforms in a dockerised environment
150+
docker run --rm -it --volume $(PWD):/go/src/github.com/elastic/fleet-server $(BUILDER_IMAGE)
151+
143152
.PHONY: release
144153
release: $(PLATFORM_TARGETS) ## - Builds a release. Specify exact platform with PLATFORMS env.
145154

0 commit comments

Comments
 (0)