Building amd64 images on Mac - Dockerfile includes R renv()

89 views Asked by At

I have the following Dockerfile to create an image to be used after testing on my Mac on a Ubuntu host. The Dockerfile includes some logic related to R's renv() package to restore denifed packages.

The Dockerfile content:

# File: Dockerfile
FROM rocker/shiny-verse:4.2.2
#FROM rocker/tidyverse:latest

RUN echo "apt-get start"
RUN apt-get update && apt-get install -y \
python3 \
cron \
nano \
tdsodbc \
odbc-postgresql \
libsqliteodbc \
libssl-dev \
libsodium-dev \
unixodbc \
unixodbc-dev \
## clean up
&& apt-get clean \ 
&& rm -rf /var/lib/apt/lists/ \ 
&& rm -rf /tmp/downloaded_packages/ /tmp/*.rds

RUN echo "apt-get end"


RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
apt-transport-https \
curl \
gnupg \
unixodbc-dev 

# Install Microsoft SQL Server driver
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 
  RUN curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update && ACCEPT_EULA=Y apt-get install msodbcsql17 

RUN echo "penfield_shinyverse_sql completed"


ENV RENV_VERSION 0.17.3
RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"

WORKDIR /project
COPY renv.lock renv.lock

# approach one
ENV RENV_PATHS_LIBRARY renv/library

# approach two
RUN mkdir -p renv
COPY .Rprofile .Rprofile
COPY renv/activate.R renv/activate.R
COPY renv/settings.json renv/settings.json

RUN R -e "renv::restore()"

When I run this via the MacOS terminal with the following code:

docker buildx build --platform linux/amd64 -t name_shiny .

I get this error message:

 => ERROR [11/18] RUN R -e "remotes::install_github('rstudio/[email protected]')"                                                                                                                                  8.4s
------                                                                                                                                                                                                            
 > [11/18] RUN R -e "remotes::install_github('rstudio/[email protected]')":
0.504 
0.504 R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
0.504 Copyright (C) 2022 The R Foundation for Statistical Computing
0.504 Platform: x86_64-pc-linux-gnu (64-bit)
0.504 
0.504 R is free software and comes with ABSOLUTELY NO WARRANTY.
0.504 You are welcome to redistribute it under certain conditions.
0.504 Type 'license()' or 'licence()' for distribution details.
0.504 
0.506   Natural language support but running in an English locale
0.506 
0.506 R is a collaborative project with many contributors.
0.506 Type 'contributors()' for more information and
0.506 'citation()' on how to cite R or R packages in publications.
0.506 
0.506 Type 'demo()' for some demos, 'help()' for on-line help, or
0.506 'help.start()' for an HTML browser interface to help.
0.506 Type 'q()' to quit R.
0.506 
0.848 > remotes::install_github('rstudio/[email protected]')
1.749 Downloading GitHub repo rstudio/[email protected]
8.040 ── R CMD build ─────────────────────────────────────────────────────────────────
8.205 Error while loading /usr/local/lib/R/bin/build: Exec format error
8.346 Error: Failed to install 'renv' from GitHub:
8.346   ! System command 'R' failed
8.347 Execution halted
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:42
--------------------
  40 |     ENV RENV_VERSION 0.17.3
  41 |     RUN R -e "install.packages('remotes', repos = c(CRAN = 'https://cloud.r-project.org'))"
  42 | >>> RUN R -e "remotes::install_github('rstudio/renv@${RENV_VERSION}')"
  43 |     
  44 |     WORKDIR /project
--------------------
ERROR: failed to solve: process "/dev/.buildkit_qemu_emulator /bin/sh -c R -e \"remotes::install_github('rstudio/renv@${RENV_VERSION}')\"" did not complete successfully: exit code: 1

When I build the same Dockerfile on a Ubuntu host I do not get the error message. Any thoughts on how to resolve this?

0

There are 0 answers