Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locating the actual Dockerfile instructions #199

Open
jforkan opened this issue Oct 1, 2024 · 4 comments
Open

Locating the actual Dockerfile instructions #199

jforkan opened this issue Oct 1, 2024 · 4 comments

Comments

@jforkan
Copy link

jforkan commented Oct 1, 2024

According to the AWS documentation on this page , I expected to see instructions within the Dockerfile that would indicate how exactly it was built.

Since it is based on AL2023 Minimal, I expected the Dockerfile to start with FROM amazonlinux:2023-minimal, with commands to install Ruby, etc. Instead it is based on FROM scratch and I see there are some included xz files, but I'm having trouble extracting those locally.

Can you help point me in the right direction?

Thanks

@leandrodamascena
Copy link

Hey @jforkan! FROM scratch is a popular method in Docker to start building minimal images, this is literally zero bytes image and from there you can add your binaries, or layers or whatever you want. I have no idea why, but It looks like Lambda built separate layers and then incorporated them into the Dockerfile to have the final image.

But I'm curious why you want to build your Lambda image from amazonlinux:2023-minimal and not from a pre-built Ruby image here. I'm not that expert in Ruby, but I have lot of Lambda in Python/TS that I build from the base image in ECR and then make customizations that I need. This is much easy because you don't need to care about installing aws_lambda_ric for Ruby, set correct PATH and other things to make it works with Lambda.

But if you still consider building your image from amazonlinux:2023-minimal, the instructions in the Using an alternative base image with the runtime interface client section on this page may help. You may need to install Ruby in the first steps, but dnf install ruby ​​-y (Ruby 3.2) can help with that. Keep in mind that amazonlinux minimal uses microdnf and you may not have all the features that you have in dnf.

Check out all the packages included in Amazon Linux 2023 minimal here.

I hope this answer helps you build your image to run on Lambda.

@jforkan
Copy link
Author

jforkan commented Oct 2, 2024

Hi @leandrodamascena, thanks for your reply.

The AWS team that produces the official lambda/ruby image (that you linked to) recently changed their base image to AL2023 Minimal going forward, which as you say has microdnf--and that's actually the pain point I'm trying to solve. There are a bunch of packages/apps that I haven't been able to install using microdnf but would be able to using the regular dnf.

So, I wanted to see if I could peek into the Dockerfile used to create that image and change the base image from amazonlinux:2023-minimal to amazonlinux:2023 while reusing the rest of their setup instructions. That seems like it should be possible, and simpler than having to write my own custom ruby image from scratch myself.

Perhaps there's a Dockerfile further upstream used to create those .xz files, but it's unclear to me how those are generated. Any idea if what I'm trying to do is possible?

@leandrodamascena
Copy link

leandrodamascena commented Oct 2, 2024

Hi @jforkan! Yes, now I understand better the challenge and I don't know if you can do it because in the file https://github.com/aws/aws-lambda-base-images/blob/ruby3.3/x86_64/41bd69298790635913afaf03b4ed358b68fdb1a16307b0fef634d7d671c6a816.tar.xz they overwrite the etc/usr/var directory, including the dnf and even if you create a new image from public.ecr.aws/amazonlinux/amazonlinux:2023 this will be overwritten. So, I really don't know if you can do this without installing everything from scratch yourself.

You can try to reproduce:

1 - Clone te repository
2 - Install the git LFS - https://docs.github.com/en/repositories/working-with-files/managing-large-files/installing-git-large-file-storage
3 - git checkout ruby3.3
4 - git lfs fetch -> git lfs install -> git lfs checkout .
5 - Modify the Dockerfile.ruby3.3 file to include FROM public.ecr.aws/amazonlinux/amazonlinux:2023 and build it.

@jforkan
Copy link
Author

jforkan commented Oct 2, 2024

Hi @leandrodamascena, thanks for the tip. Now that I've installed lfs I can see the contents of the xz files and this gives me something to work with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants