Skip to content

Commit

Permalink
feat: add support for reproducible builds (#237)
Browse files Browse the repository at this point in the history
* feat: add support for reproducible builds

Add support for SOURCE_DATE_EPOCH to avoid timestamp and timezones
issues.

See https://reproducible-builds.org/specs/source-date-epoch/

Make sure zip entries have a consistent mtime and strip extra
attributes.

See https://reproducible-builds.org/docs/archives/

Zip archives are now reproducible by default. Update script
to use the make task and avoid calling zip directly.

* refactor: remove unused conditional

Co-authored-by: Andrew Wilkins <axwalk@gmail.com>

* feat: default SOURCE_DATE_EPOCH to the last commit timestamp

Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
  • Loading branch information
kruskall and axw authored Jul 21, 2022
1 parent d478d5f commit 65cd5df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion apm-lambda-extension/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ DOCKER_IMAGE_NAME = observability/apm-lambda-extension
DOCKER_REGISTRY = docker.elastic.co
AGENT_VERSION = $(shell echo $${BRANCH_NAME} | cut -f 2 -d 'v')

# Add support for SOURCE_DATE_EPOCH and reproducble buils
# See https://reproducible-builds.org/specs/source-date-epoch/
SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct)

ifndef GOARCH
GOARCH=amd64
endif
Expand Down Expand Up @@ -56,7 +60,11 @@ endif
GOARCH=${GOARCH} make zip
$(MAKE) publish
zip:
cd bin && rm -f extension.zip || true && zip -r extension.zip extensions NOTICE.txt dependencies.asciidoc && cp extension.zip ${GOARCH}.zip
cd bin \
&& rm -f extension.zip \
&& find extensions NOTICE.txt dependencies.asciidoc | xargs touch -d @$(SOURCE_DATE_EPOCH) \
&& zip -X -r extension.zip extensions NOTICE.txt dependencies.asciidoc \
&& cp extension.zip ${GOARCH}.zip
test:
go test extension/*.go -v
env:
Expand Down
2 changes: 1 addition & 1 deletion apm-lambda-extension/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

# build the go extension, and then zip up
make all && cd bin && zip -r extension.zip extensions
make all && make zip

# then run this command with amazon stuff exported

Expand Down

0 comments on commit 65cd5df

Please sign in to comment.