Skip to content

Instantly share code, notes, and snippets.

@imjma
Created March 13, 2023 01:00
Show Gist options
  • Save imjma/e9d46110ff24614fa763ea19d2a6e042 to your computer and use it in GitHub Desktop.
Save imjma/e9d46110ff24614fa763ea19d2a6e042 to your computer and use it in GitHub Desktop.
lambda golang docker local
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" ]
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