Minimize requirements for modelServr

Ensure we can install dependencies as part of modelServR install
Optimize the worker docker image to minimal size required
This commit is contained in:
Clinton.Collins 2019-05-07 13:37:47 -07:00
Родитель 19b2845721
Коммит d4280a0841
5 изменённых файлов: 25 добавлений и 29 удалений

Просмотреть файл

@ -1,4 +1,4 @@
FROM rocker/r-base:3.5.3
FROM rocker/r-base
LABEL description="Environment to execut model queries against"
LABEL authors="ccollins@idmod.org"
@ -6,31 +6,26 @@ LABEL authors="ccollins@idmod.org"
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBCONF_NONINTERACTIVE_SEEN=true
# install packages required and then cleanup
RUN apt-get update && apt-get install -y \
# required by devtools and ggmap
libssl-dev libcurl4-gnutls-dev \
# required by sf
libudunits2-dev libgdal-dev \
# required by INLA or a dependency of INLA
libxml2-dev libx11-dev texlive-binaries libglu1-mesa-dev libfreetype6-dev \
# required by geojsonio or a dependency of geojsonio
libgdal-dev libgeos-c1v5 libproj-dev libv8-dev libjq-dev libprotobuf-dev protobuf-compiler \
# Git for development tools
git-core git libgit2-dev && \
# cleanup apt cache to reduce final image size
rm -rf /var/lib/apt/lists/*
libssl-dev libcurl4-gnutls-dev
# Set default make to parallel build
ENV MAKE="make -j8"
RUN Rscript -e "install.packages(c('devtools'))" \
&& rm -rf /tmp/*
ARG MODEL_SERVR_VERSION=0.0.0.9000
RUn mkdir -p /worker
# ADD our model file
ADD modelServR.tar.gz /tmp
RUN Rscript -e "install.packages("/tmp/modelServR.tar.gz", repos = NULL, type="source")"
COPY modelServR/modelServR_${MODEL_SERVR_VERSION}.tar.gz /worker/modelServR.tar.gz
WORKDIR /worker
RUN cd /worker && \
Rscript -e 'untar("modelServR.tar.gz", exdir="/tmp")' && \
Rscript -e 'devtools::install("/tmp/modelServR", dependencies=TRUE)' && \
rm -rf /tmp/* /worker/*.tar.gz
# Our Organization(as others do) map Active Directory to LDAP for linux
# These means when mapping in our userids
# These means when mapping in our us
# docker -e USERID=$UID....
# which remaps the rstudio UID,
# the user ids can be large. To suppor that we need to update login.defs

Просмотреть файл

@ -1,4 +1,4 @@
BUILD_CONTAINER_NAME ?= idm-docker-staging.packages.idmod.org/sfim_build_env:latest
BUILD_CONTAINER_NAME ?= idm-docker-staging.packages.idmod.org/sfim-build-env:latest
DEPLOY_SERVER ?= 40.112.165.255
DEPOLY_USERNAME ?= useradmin
@ -22,8 +22,11 @@ build-r-package: pull-r-env ## Build the r package as tar ball
# We have to run this with the build user's ids
# otherwise we end up with files we cannot modify
docker run -u $(shell id -u):$(shell id -g) \
-v $(PWD)/predictModelTestPkg:/app -w /app $(BUILD_CONTAINER_NAME) \
R CMD build .
-v $(PWD)/:/app \
-w /app $(BUILD_CONTAINER_NAME) \
bash -c "cd dbViewR && R CMD build . && \
cd ../incidenceMapR && R CMD build . && \
cd ../modelServR && R CMD build ."
build-api: build-r-package get_version ## Builds the api
-mkdir -p api_service/models

Просмотреть файл

@ -16,7 +16,7 @@ services:
build:
context: api_service
dockerfile: Dockerfile
image: idm-docker-production.packages.idmod.org/sfim:${version:-latest}
image: idm-docker-production.packages.idmod.org/sfim-api:${version:-latest}
volumes:
- "/model_store:/model_store"
environment:

Просмотреть файл

@ -11,3 +11,7 @@ License: What license it uses
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Imports:
digest,
jsonlite,
logging

Просмотреть файл

@ -2,11 +2,5 @@
export(returnModel)
export(saveModel)
import(dbViewR)
import(digest)
import(jsonlite)
import(magrittr)
importFrom(RCurl,getURL)
importFrom(dplyr,group_by_at)
importFrom(jsonlite,toJSON)
importFrom(tidyr,nest)
import(jsonlite)