Created
March 13, 2023 01:00
-
-
Save imjma/e9d46110ff24614fa763ea19d2a6e042 to your computer and use it in GitHub Desktop.
lambda golang docker local
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM public.ecr.aws/lambda/provided:al2 as build | |
# install compiler | |
RUN yum install -y golang | |
RUN go env -w GOPROXY=direct | |
# cache dependencies | |
ADD go.mod go.sum ./ | |
RUN go mod download | |
# build | |
ADD . . | |
RUN go build -o /main lambda/purge/main.go | |
# copy artifacts to a clean image | |
FROM public.ecr.aws/lambda/provided:al2 | |
COPY --from=build /main /main | |
# ENTRYPOINT [ "/main" ] | |
RUN mkdir -p /opt/extensions | |
# need use rie to run on local | |
ENTRYPOINT [ "aws-lambda-rie", "/main" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t lambda-app . | |
docker run -v $(HOME)/.aws:/root/.aws \ | |
-e AWS_REGION=$(AWS_REGION) -e AWS_PROFILE=$(AWS_PROFILE) \ | |
-p 9000:8080 \ | |
lambda-app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment