Skip to content

multi-stage dockerfile: This reduces image size to half compare to ea… #200

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

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

StarTrooper08
Copy link
Collaborator

multi-stage dockerfile: This reduces image size to half compare to earlier image version size.

Before multi-stage build
image

After multi-stage build(r-multi-stage build -> r-dev-env image)
image

@hturner
Copy link
Member

hturner commented Mar 21, 2025

This looks okay to me, but I see ubuntu 22.04 is hard-coded. Maybe we can use ubuntu-latest to avoid needed to update later?

@StarTrooper08
Copy link
Collaborator Author

If we use just ubuntu instead of ubuntu:22, it will automatically used as latest.
Will make the following change and also have a look over build process.

@hturner
Copy link
Member

hturner commented Jun 6, 2025

If we use ubuntu latest, then we can also prefer r-universe over CRAN when installing R packages, so that we install from the linux binary rather than from source, i.e.

&& Rscript -e "install.packages(c('languageserver', 'httpgd'), \
repos = c(runiverse='https://r-universe.dev', CRAN='https://cloud.r-project.org'))" \

This should save quite a lot of time in the build.

@StarTrooper08
Copy link
Collaborator Author

Sure updating the file shortly.

@remlapmot
Copy link

(I was just randomly follow a few R dev related repos) Just to point out that URL for the r-universe cran linux binary repo doesn't look correct - as far as I know it is

https://cran.r-universe.dev/bin/linux/noble-x86_64/4.5/

which you can infer from https://docs.r-universe.dev/install/binaries.html

or by hovering your mouse over a Linux package on any package page under https://cran.r-universe.dev/ e.g. https://cran.r-universe.dev/MRAM

and httpgd (as regularly happens) currently isn't on CRAN so you can obtain that from it's developer's r-universe

&& Rscript -e "install.packages(c('languageserver', 'httpgd'), \
repos = c(runiverse='https://cran.r-universe.dev/bin/linux/noble-x86_64/4.5/', \
  nx10 = 'https://nx10.r-universe.dev/bin/linux/noble-x86_64/4.5/'))" \

@hturner
Copy link
Member

hturner commented Jun 9, 2025

Thanks for the correction @remlapmot. We don't want to hardcode the distro, architecture or R version, so we can do

Rscript -e "runiverse <- sprintf('r-universe.dev/bin/linux/%s-%s/%s/', \
                                 system2('lsb_release', '-sc', stdout = TRUE), \
                                 R.version\$arch, \
                                 substr(getRversion(), 1, 3)); \
            install.packages(c('languageserver', 'httpgd'), \
                 repos = c(runiverse = paste0('https://cran.', runiverse), \
                           nx10 = paste0('https://nx10.', runiverse)))"   

I've tested this out in a Rocker container to confirm it works.

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

Successfully merging this pull request may close these issues.

3 participants