Build app image from alpine linux

I wanna build off of rhub/r-minimal which is alpine linux.

Dockerfile looks something like this:

FROM rhub/r-minimal

LABEL build_date="2022-07-28"
LABEL version=0.1

RUN apk add --no-cache gmp-dev curl curl-dev libxml2-dev libgit2-dev

RUN mkdir /root/app
COPY . /root/app

RUN mkdir /usr/lib/R
RUN mkdir /usr/lib/R/etc/
COPY Rprofile.site /usr/lib/R/etc/
  
WORKDIR /root/app

RUN installr -d -t "file automake autoconf linux-headers zlib-dev make" renv data.table magrittr \
             openxlsx shiny shinyWidgets shinyBS shinyvalidate shinycssloaders \
             shinybusy shinyjs htmlwidgets logging lubridate DT stringi glue
  
EXPOSE 3838

CMD ["R", "-e", "shiny::runApp('/root/app')"]

Builds all right however the docker container is not being started, not even a log is given, which means to me it is not being found by shinyproxy.

Is there anything specific about alpine linux derrived app aimages?

Can you share what error message do you get?
Have you tried running the app from the container outside shinyproxy? (as described in https://www.shinyproxy.io/faq/#container-did-not-respond-in-time)

1 Like

The error was 500, did not respond in time. Meanwhile I managed to find the correct settings, the complete reprex that worked for me now is as follows (inspired by https://hosting.analythium.io/best-practices-for-r-with-docker/):

FROM rhub/r-minimal

LABEL build_date="2022-07-29"
LABEL version=0.8

RUN apk update
RUN apk add --no-cache \
            --update-cache \
            autoconf \
            automake \
            bash \
            tzdata

RUN echo "Europe/Berlin" > /etc/timezone

RUN installr -d \
            -t "file linux-headers libxml2-dev gnutls-dev openssl-dev libx11-dev cairo-dev libxt-dev" \
            -a "libxml2 cairo libx11 font-xfree86-type1 icu R-dev" \
            Cairo \
            bit64 \
            data.table \
            magrittr \
            openxlsx \
            shiny \
            shinydashboard \
            shinyWidgets \
            shinyBS \
            shinyvalidate \
            shinycssloaders \
            shinybusy \
            shinyjs \
            htmlwidgets \
            logging \
            lubridate \
            DT \
            stringi \
            glue 

RUN mkdir /usr/lib/R
RUN mkdir /usr/lib/R/etc/
COPY Rprofile.site /usr/lib/R/etc/

RUN mkdir /home/app
WORKDIR /home/app
COPY global.R .
COPY server.R .
COPY ui.R .
COPY www www

RUN rm -rf /var/cache/apk/*
  
RUN addgroup --system app && adduser --system --ingroup app app
RUN chown app:app -R /home/app
USER app

EXPOSE 3838

CMD ["R", "-e", "options(tz='Europe/Berlin', shiny.port = 3838, shiny.host = '0.0.0.0'); shiny::runApp('/home/app')"]

Tested a run with:
sudo docker run -it -p 3899:3838 -v /xyz/abc/:/xyz/adb app11_alpine:latest
then visited the server locally, open localhost:3899 to see if the app runs Okay in live docker run session, then I could deploy in production.

Reduced size of the image by 40%. Nice. Thanks.