-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
52 lines (41 loc) · 1.08 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
46
47
48
49
50
51
52
.PHONY: all clean build
all: build
clean:
-rm handler.zip
# -----------------------------------------
# Lambda management
LAMBDA_S3_BUCKET := buildkite-aws-stack-lox
LAMBDA_S3_BUCKET_PATH := /
export CGO_ENABLED := 0
ifdef BUILDKITE_BUILD_NUMBER
LD_FLAGS := -s -w -X version.Build=$(BUILDKITE_BUILD_NUMBER)
BUILDVSC_FLAG := false
USER := 0:0
endif
ifndef BUILDKITE_BUILD_NUMBER
LD_FLAGS := -s -w
BUILDVSC_FLAG := true
USER := "$(shell id -u):$(shell id -g)"
endif
build: handler.zip
handler.zip: bootstrap
zip -9 -v -j $@ "$<"
bootstrap: lambda/main.go
docker run \
--env GOCACHE=/go/cache \
--env CGO_ENABLED \
--user $(USER) \
--volume $(PWD):/app \
--workdir /app \
--rm \
golang:1.22 \
go build -ldflags="$(LD_FLAGS)" -buildvcs="$(BUILDVSC_FLAG)" -tags lambda.norpc -o bootstrap ./lambda
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