# Build app image from alpine linux

**URL:** <https://support.openanalytics.eu/t/build-app-image-from-alpine-linux/2327>\
**Category:** ShinyProxy\
**Created:** [July 28, 2022, 5:33pm UTC](https://support.openanalytics.eu/t/build-app-image-from-alpine-linux/2327 "2022-07-28T17:33:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat](https://support.openanalytics.eu/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@Pat](https://support.openanalytics.eu/u/Pat)\
**Post date:** [July 28, 2022, 5:33pm UTC](https://support.openanalytics.eu/t/build-app-image-from-alpine-linux/2327/1 "2022-07-28T17:33:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mnazarov](https://support.openanalytics.eu/user_avatar/support.openanalytics.eu/mnazarov/32/216_2.png) [@mnazarov](https://support.openanalytics.eu/u/mnazarov)\
**Post date:** [July 28, 2022, 10:34pm UTC](https://support.openanalytics.eu/t/build-app-image-from-alpine-linux/2327/2 "2022-07-28T22:34:52Z")

</div>

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](https://www.shinyproxy.io/faq/#container-did-not-respond-in-time))

---

<div class="post-metadata">

**Author:** ![Pat](https://support.openanalytics.eu/letter_avatar_proxy/v4/letter/p/8491ac/32.png) [@Pat](https://support.openanalytics.eu/u/Pat)\
**Post date:** [July 29, 2022, 11:09am UTC](https://support.openanalytics.eu/t/build-app-image-from-alpine-linux/2327/3 "2022-07-29T11:09:08Z")

</div>

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/](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.
