Skip to content

Instantly share code, notes, and snippets.

@kirel
Created March 3, 2019 10:15
Show Gist options
  • Save kirel/9b0836bbb5a3f927eadea8083c2e2336 to your computer and use it in GitHub Desktop.
Save kirel/9b0836bbb5a3f927eadea8083c2e2336 to your computer and use it in GitHub Desktop.
FROM r-base:3.5.2
RUN apt-mark hold r-base-core
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libcurl4-gnutls-dev \
libxml2-dev \
libmariadbclient-dev \
libssl-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/*
ENV API_ROOT /opt/r-rest-api
ARG GITHUB_PAT
RUN if [ -z "${GITHUB_PAT}" ]; then >&2 echo "ERROR: GitHub private access token is missing. Please run with '--build-arg GITHUB_PAT=YOUR_GITHUB_TOKEN'."; exit 1; fi
# App dependencies
RUN R -e "withCallingHandlers({ install.packages('devtools'); devtools::install_github('rstudio/packrat') }, warning = function(w) stop(w))"
COPY ./packrat $API_ROOT/packrat
WORKDIR $API_ROOT
RUN R -e "withCallingHandlers({ packrat::restore() }, warning = function(w) stop(w))"
RUN R -e "withCallingHandlers({ packrat::init() }, warning = function(w) stop(w))"
COPY ./R $API_ROOT/R
EXPOSE 8000
CMD ["Rscript", "/opt/r-rest-api/R/plumb.R"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment