Skip to content

Instantly share code, notes, and snippets.

@Patrikios
Last active September 20, 2022 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Patrikios/475fbc042fe36ffc74e3de3c8dcc569a to your computer and use it in GitHub Desktop.
Save Patrikios/475fbc042fe36ffc74e3de3c8dcc569a to your computer and use it in GitHub Desktop.
Building a shinyproxy Dockerfile based on rhub/r-minimal for R shiny app
# Ressources:
# - https://github.com/r-hub/r-minimal
# - https://hosting.analythium.io/best-practices-for-r-with-docker/
# NOTE
# does not support Cairo or x11 add hoc, hence renderPlot will not work, renderPlotly und JS backends are working fine
# TEST and DEBUG
# - build: sudo docker build --build-arg http_proxy=x --build-arg https_proxy=x -t shiny_app_alpine .
# - run: sudo docker run -it -p 3899:3838 -v /home/xyz/:/home/xyz/ shiny_app_alpine
# - then visit the server locally and open localhost:3899 to see and test the app in live docker run session
FROM rhub/r-minimal
RUN apk update
RUN apk add --no-cache \
--update-cache \
autoconf \
automake \
bash \
tzdata
RUN echo "Europe/Berlin" > /etc/timezone
ENV HTTP_PROXY="x"
ENV HTTPS_PROXY="x"
# install packages with 'installr' utility of 'rhub/r-minimal', for instance:
RUN installr -d \
-t "file linux-headers libxml2-dev gnutls-dev openssl-dev libxt-dev" \
-a "libxml2 libx11 font-xfree86-type1 icu R-dev mariadb-dev" \
waiter \
config \
pool\
logging \
ISOweek \
DBI \
RMariaDB \
shiny \
shinydashboard \
shinyWidgets \
shinyjs\
htmlwidgets \
shinyBS \
plotly \
openxlsx \
formattable \
shinycssloaders \
data.table \
DT \
ggplot2 \
shinybusy \
dplyr \
future \
promises \
lubridate \
truncnorm Rsolnp #dependencies for qualityTools
# custom packages install from archive, for instance:
RUN R -e "url <- 'https://cran.r-project.org/src/contrib/Archive/qualityTools/qualityTools_1.55.tar.gz'; \
pkgFile <- 'qualityTools_1.55.tar.gz'; \
download.file(url = url, destfile = pkgFile); \
install.packages(pkgs=pkgFile, type='source'); \
unlink(pkgFile)"
LABEL maintainer="john.doe@company-international.com"
LABEL build_date="2022-09-20"
LABEL version=1.2.3
RUN mkdir /home/app
WORKDIR /home/app
COPY local_app/global.R .
COPY local_app/server.R .
COPY local_app/ui.R .
COPY local_app/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')"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment