File tree Expand file tree Collapse file tree 14 files changed +104
-27
lines changed Expand file tree Collapse file tree 14 files changed +104
-27
lines changed Original file line number Diff line number Diff line change 20
20
go-version : ' ~1.18.2'
21
21
22
22
- name : Build
23
+ env :
24
+ RELEASE_BUILD_LINKER_FLAGS : " -s -w"
23
25
run : make compile-lambda-linux-all
24
26
25
27
- uses : actions/upload-artifact@v3
Original file line number Diff line number Diff line change 5
5
# RELEASE_BUILD_LINKER_FLAGS disables DWARF and symbol table generation to reduce binary size
6
6
# RELEASE_BUILD_LINKER_FLAGS=-s -w
7
7
8
-
9
8
BINARY_NAME =aws-lambda-rie
10
9
ARCH =x86_64
11
10
GO_ARCH_x86_64 := amd64
@@ -25,7 +24,7 @@ compile-with-docker:
25
24
docker run --rm --env GOPROXY=direct -v $(shell pwd) :/LambdaRuntimeLocal -w /LambdaRuntimeLocal golang:1.18 make ARCH=${ARCH} compile-lambda-linux
26
25
27
26
compile-lambda-linux :
28
- CGO_ENABLED=0 GOOS=linux GOARCH=${GO_ARCH_${ARCH} } go build -ldflags " ${RELEASE_BUILD_LINKER_FLAGS} " -gcflags=" all=-N -l " -o ${DESTINATION_${ARCH} } ./cmd/localstack
27
+ CGO_ENABLED=0 GOOS=linux GOARCH=${GO_ARCH_${ARCH} } go build -ldflags " ${RELEASE_BUILD_LINKER_FLAGS} " -gcflags=" ${GC_FLAGS} " -o ${DESTINATION_${ARCH} } ./cmd/localstack
29
28
30
29
tests :
31
30
go test ./...
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ aws-lambda-rie
2
+ build-delve /dlv
3
+ init /var /rapid /init
4
+ init /var /rapid /dlv
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ # Golang EOL overview: https://endoflife.date/go
2
+ DOCKER_GOLANG_IMAGE ?= golang:1.18.2
3
+
4
+ # On ARM hosts, use: make ARCH=arm64 build-init
5
+ # Check host architecture: uname -m
6
+ # x86_64 or arm64
7
+ ARCH ?= x86_64
8
+
9
+ ifeq ($(ARCH ) , arm64)
10
+ GOARCH =arm64
11
+ else
12
+ GOARCH =amd64
13
+ endif
14
+
15
+ # Limitation: Debugging x86_64 lambdas does not work on ARM machines due to missing ptrace implementation in qemu used by Docker
16
+ # The function aborts with "could not launch process: fork/exec /var/rapid/init: function not implemented"
17
+ # * Discussion: https://github.com/aws/aws-sam-cli/discussions/4706
18
+ # * Docker for Mac: https://github.com/docker/for-mac/issues/5191#issuecomment-834154431
19
+
20
+
21
+ all : build
22
+
23
+ # build & "package" necessary files for debugging
24
+ build build-init : build-rapid build-delve/dlv
25
+ cp ../bin/aws-lambda-rie-$(ARCH ) ./init/var/rapid/init
26
+ cp ./build-delve/dlv ./init/var/rapid/dlv
27
+
28
+ build-rapid :
29
+ cd .. && GC_FLAGS=" all=-N -l" make ARCH=$(ARCH ) compile-lambda-linux
30
+
31
+ build-delve/dlv :
32
+ docker run --rm -v $$(pwd ) /build-delve/:/app/ $(DOCKER_GOLANG_IMAGE ) \
33
+ bash -c " cd /app && export GOARCH=$( GOARCH) && ./build.sh"
34
+
35
+ clean clean-init : clean-rapid clean-delve
36
+
37
+ clean-rapid :
38
+ rm -rf ../bin/aws-lambda-rie-*
39
+ rm -rf ./init/var/rapid/init
40
+
41
+ clean-delve :
42
+ rm -rf ./build-delve/dlv
43
+ rm -rf ./init/var/rapid/dlv
44
+
45
+ .PHONY : build build-rapid clean clean-rapid clean-delve
Original file line number Diff line number Diff line change
1
+ # Testing lambda-runtime-init
2
+
3
+ ## Testing in isolation
4
+ Useful if you want more control over the API between the init and LocalStack (e.g. for error responses)
5
+
6
+
7
+ ## Debugging with LocalStack
8
+
9
+ 1 . Build init via ` make build `
10
+ * On ARM hosts, use ` make ARCH=arm64 build `
11
+
12
+ 2 . Start LocalStack with the following flags:
13
+
14
+ ```
15
+ LAMBDA_INIT_BIN_PATH=/Users/joe/Projects/LocalStack/lambda-runtime-init/custom-tests/init/var/rapid/init
16
+ LAMBDA_INIT_BOOTSTRAP_PATH=/Users/joe/Projects/LocalStack/lambda-runtime-init/custom-tests/init/var/rapid/entrypoint.sh
17
+ LAMBDA_INIT_DEBUG=1
18
+ LAMBDA_INIT_DELVE_PATH=/Users/joe/Projects/LocalStack/lambda-runtime-init/custom-tests/init/var/rapid/dlv
19
+ LAMBDA_INIT_DELVE_PORT=40000
20
+ LAMBDA_RUNTIME_ENVIRONMENT_TIMEOUT=3600
21
+ TEST_DISABLE_RETRIES_AND_TIMEOUTS=1
22
+ ```
23
+
24
+ * `LAMBDA_INIT_DEBUG=1|0` enables or disables RIE copying and debugging.
25
+ * `LAMBDA_REMOVE_CONTAINERS=0` keeps exited containers
26
+ * Adjust the path to `lambda-runtime-init` accordingly
27
+
28
+ 3. Start Delve debugger and connect to `localhost:40000`
29
+
30
+
31
+ ### Advice for function configuration
32
+
33
+ Within `create_lambda_function`:
34
+
35
+ * Increase the `timeout=3600`
36
+ * On ARM hosts, use `Architectures=[Architecture.arm64]`
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ mkdir -p /tmp/build-delve
4
+ cd /tmp/build-delve
5
+ git clone https://github.com/go-delve/delve.git
6
+ cd delve
7
+ make build
8
+ mv dlv /app/dlv
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ LAMBDA_INIT_DELVE_PORT=" ${LAMBDA_INIT_DELVE_PORT:- 40000} "
4
+
5
+ # Run init without delve debugger
6
+ # exec /var/rapid/init
7
+
8
+ exec /var/rapid/dlv --listen=:${LAMBDA_INIT_DELVE_PORT} --headless=true --api-version=2 --accept-multiclient exec /var/rapid/init
You can’t perform that action at this time.
0 commit comments