forked from buildkite/buildkite-agent-scaler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (34 loc) · 1.01 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
.PHONY: all clean build
all: build
clean:
-rm handler.zip
# -----------------------------------------
# Lambda management
LAMBDA_S3_BUCKET := buildkite-aws-stack-lox
LAMBDA_S3_BUCKET_PATH := /
ifdef BUILDKITE_BUILD_NUMBER
LD_FLAGS := -s -w -X version.Build=$(BUILDKITE_BUILD_NUMBER)
endif
ifndef BUILDKITE_BUILD_NUMBER
LD_FLAGS := -s -w
endif
build: handler.zip
handler.zip: lambda/handler
zip -9 -v -j $@ "$<"
lambda/handler: lambda/main.go
docker run \
--volume go-module-cache:/go/pkg/mod \
--volume $(PWD):/go/src/github.com/buildkite/buildkite-agent-scaler \
--workdir /go/src/github.com/buildkite/buildkite-agent-scaler \
--rm golang:1.15 \
go build -ldflags="$(LD_FLAGS)" -o ./lambda/handler ./lambda
chmod +x lambda/handler
lambda-sync: handler.zip
aws s3 sync \
--acl public-read \
--exclude '*' --include '*.zip' \
. s3://$(LAMBDA_S3_BUCKET)$(LAMBDA_S3_BUCKET_PATH)
lambda-versions:
aws s3api head-object \
--bucket ${LAMBDA_S3_BUCKET} \
--key handler.zip --query "VersionId" --output text