mdneuzerling / lambdr

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

Update README example to use Rocker #39

Closed mdneuzerling closed 2 weeks ago

mdneuzerling commented 3 weeks ago

Removes any mention of Amazon Linux from the README, and replaces the example with a Dockerfile that uses Rocker.

Closes #38

mdneuzerling commented 3 weeks ago

Yep, so in the README example I found that the curl installation (first RUN line) was necessary for the pak installation:

FROM docker.io/rocker/r-ver:4.4

# curl is required for {pak}
RUN apt-get update && apt-get -y install --no-install-recommends curl 

# options(warn=2) will make the build error out if package doesn't install
RUN Rscript -e "options(warn = 2); install.packages('pak')"

# Using {pak} to install R packages: it resolves Ubuntu system dependencies AND
# the R dependency tree. Other required packages can be installed here.
RUN Rscript -e "pak::pak('lambdr')"

RUN mkdir /R
COPY runtime.R /R
RUN chmod 755 -R /R

ENTRYPOINT Rscript R/runtime.R
CMD ["parity"]
jimgar commented 3 weeks ago

Ahh, I think I've got it.

I can get your Dockerfile above to work if I remove the curl installation and specify --platform="linux/amd64" at build time instead, like so

docker build -t no-httr-test:latest . --platform="linux/amd64"

Can you give that a try too?

The r-ver images apparently point to the Posit Public Package Manager Linux binaries... but without specifying the platform, Docker pulls the 'unknown/unknown' version of the image, with R subsequently trying to install from source instead of Ubuntu binaries. The source installation requires curl.

jimgar commented 3 weeks ago

If it works for you too (🤞🏻), perhaps update the readme instructions on line 154 from:

docker build -f dockerfile -t r-on-lambda .

To:

docker build -f dockerfile -t r-on-lambda . --platform="linux/amd64"

And I can revisit the vignettes to consider where it is worth noting this behaviour.

mdneuzerling commented 2 weeks ago

Good call. I've added the build platform. I removed the -f option though. I don't think that's necessary.

If everything looks good could you please approve and merge?