mdneuzerling / lambdr

Run R containers on AWS Lambda
https://lambdr.mdneuzerling.com
Other
131 stars 12 forks source link

Update README.md #32

Closed anisfeld closed 10 months ago

anisfeld commented 10 months ago

Thanks for this package!

I believe Amazon changed the default al2 to use amd64 architecture, so the current dockerfile wouldn't build. With the small tweak here it worked for me, but it took a long time to figure that out!

mdneuzerling commented 10 months ago

Thanks for this!

Should we encourage folks to use the --platform flag in docker build instead? eg.

docker build --platform amd64 . docker build --platform linux/arm64 .

If this is a good solution then I can add some notes to the README and vignettes to let people know about this flag.

anisfeld commented 10 months ago

So the issue I faced was that the provided image automatically is amd64

FROM public.ecr.aws/lambda/provided:al2

But then the R release requires x86_64:

RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
  && wget https://cdn.rstudio.com/r/centos-7/pkgs/R-${R_VERSION}-1-1.x86_64.rpm \
  && yum -y install R-${R_VERSION}-1-1.x86_64.rpm \
  && rm R-${R_VERSION}-1-1.x86_64.rpm

So the simplest solution seems to be to specify the architecture in the provided tag as I do in the updated Readme .

FROM public.ecr.aws/lambda/provided:al2-x86_64

I think that's easier than specifying the platform with docker build as someone somewhat new to docker.

I also added the docker build code (docker build -f dockerfile -t mdneuzerling/r-on-lambda .) for completeness since I had forgotten how to add the tag, which is necessary for the ecr steps.

mdneuzerling commented 10 months ago

That makes sense! Thank you for that. I've removed my username from the tag but otherwise this is good to go and I'll merge once the tests finish.