aws / aws-lambda-base-images

Apache License 2.0
648 stars 107 forks source link

Where does lambda-entrypoint.sh come from? #17

Open adlythebaud opened 3 years ago

adlythebaud commented 3 years ago

In each dockerfile, the entrypoint command is ENTRYPOINT ["/lambda-entrypoint.sh"]. Where does that lambda-entrypoint.sh script come from? Do I need to create it myself, or is it present in the tar files that the dockerfile pulls in?

brsanthu commented 2 years ago

It is there in https://github.com/aws/aws-lambda-base-images/blob/nodejs14.x/668a80b661f539fe33666ac42826025bcb7cd59a60cc2c68f4b9f298c3ca6850.tar.xz

jrnp97 commented 2 years ago

the file is not more available?

techfort commented 2 years ago

gotta bump this, when i run docker build -t python3.8:local -f Dockerfile.python3.8 . and then docker run python3.8:local it gives docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/lambda-entrypoint.sh": stat /lambda-entrypoint.sh: no such file or directory: unknown. ERRO[0000] error waiting for container: context canceled

carlzogh commented 2 years ago

Hello,

in order to be able to help you better, could you please include a copy of the contents of the Dockerfile used to build the image?

/lambda-entrypoint.sh is inherited from the base image (ie. public.ecr.aws/lambda/{runtime}) and is set as the ENTRYPOINT in order to detect whether the image is being run in Lambda or not, to decide whether to invoke the function through the Runtime Interface Emulator or directly if running in Lambda cloud.

https://docs.aws.amazon.com/lambda/latest/dg/images-test.html

dickermoshe commented 2 years ago

I'm having the exact same issue as @techfort The content of the Dockerfile is how it appears in the repo: I'm running the ARM Dockerfile of the Python 3.8 Repo

https://github.com/aws/aws-lambda-base-images/blob/python3.8/arm64/Dockerfile.python3.8

For some reason the built image is only 788 Bytes. Why are the ADD commands not working ?

lamermoon commented 2 years ago

For me, installing and configuring git-lfs before checking out the desired branch (python3.9 in my case) and building the image solved the issue.

If git-lfs is not installed or configured correctly, all the *.tar.xz files are ~130B in size and only contain text, which is why the ADD command does not work as expected.

On Ubuntu you can install git-lfs with sudo apt install git-lfs. After installing git-lfs you need to run git lfs install once per user account. Checking out the python3.9 branch now will download the *.tar.xz files. E.g. aws-lambda-base-images/x86_64/07b31686e40e69488bf3dfb150a1004c8a6c59fb41645305ddeb01ac079fe9b4.tar.xz has ~48MB. If you now build the docker image again and start the container, you should be good to go.

smirnoal commented 1 year ago

has the original problem been solved after installing git lfs?

nojohnny101 commented 1 year ago

@lamermoon solution worked for me. I got the same error as @techfort

ended up I didn't have git-lfs installed. installed via home-brew and it is not working.

Thanks!

shirakaba commented 1 year ago

This issue will happen if you download a zip of the repo rather than cloning it via git.

That said, even though I subsequently installed git-lfs and cloned the repo, it didn't take any effect.

Here's how I got it running, though:

# Clone the repo
git clone https://github.com/aws/aws-lambda-base-images
cd aws-lambda-base-images

# Check out the branch of choice
git checkout nodejs18.x

# fetch the large files (this may be redundant, but that's what I did anyway)
git lfs fetch

# I needed to add sudo, but that may be unique to my setup (installed git-lfs via Nix)
sudo git lfs install

# Do a git checkout, downloading the large files
git lfs checkout .

# Build the image, naming it `nodejs18.x:local`
docker build --no-cache -t nodejs18.x:local -f Dockerfile.nodejs18.x .

# Run a container from the image named `nodejs18.x:local`.
# We need to pass it the handler name as our first argument...
# However, I don't yet know what to put for that, so I've put an empty
# string provisionally 🤷‍♂️ that's a separate problem!
docker run -p 9000:8080 nodejs18.x:local ""
agalazis commented 1 year ago

for those interested in seeing the content of the file just check it within the docker image: docker run --rm -it --entrypoint /bin/bash public.ecr.aws/lambda/python:3.10 then if you run ls / you can see it there then cat /lambda-entrypoint.sh to see its contents

AndreMiras commented 10 months ago

Thanks and the one of for the lazy:

docker run --rm -it --entrypoint /bin/bash public.ecr.aws/lambda/python:3.11 -c "cat /lambda-entrypoint.sh"