-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
73 lines (62 loc) · 2.6 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
FROM rstudio/plumber:latest
ENV TZ="Africa/Nairobi"
# install base libraries we need
RUN apt-get -y update -qq && apt-get -y --no-install-recommends install \
tini \
libmariadb-dev \
libmysqlclient21 \
openjdk-8-jdk-headless \
cron \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /etc/cron.*/*
# install the R packages we need
# for these, the latest version should always be usable
RUN install2.r --error --skipinstalled \
tidyverse \
pool \
clock \
config \
uuid \
readr \
RMariaDB \
DBI \
h2o \
&& rm -rf /tmp/downloaded_packages
# The next scripts are used for cron jobs
# this script triggers the predictions to run by hitting the API endpoint
COPY docker-resources/run_predictions.sh /app/run_predictions.sh
RUN chmod 0744 /app/run_predictions.sh
# this script runs a small number of stored procedures we depend on to update
# various tables used in the predictions
COPY docker-resources/run_daily_stored_procedures.sh /app/run_daily_stored_procedures.sh
RUN chmod 0744 /app/run_daily_stored_procedures.sh
# this is a Docker entrypoint script
# it ensures the cron daemon is started and then runs the API
COPY docker-resources/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod 0744 /docker-entrypoint.sh
# here we actually setup the cron jobs, using our source crontab
# cron is _very_ picky, so it may not be best to mess with this
COPY docker-resources/crontab /etc/cron.d/iit-crontab
RUN chmod 0644 /etc/cron.d/iit-crontab
RUN crontab -u root /etc/cron.d/iit-crontab
# Add the prediction models to the app
COPY IIT-Prediction/model/V11 /app/model
# Add the production extraction query to the app
COPY SQL/iit_prod_data_extract.sql /app/iit_prod_data_extract.sql
# Add the procution threshold queries to the app
COPY SQL/iit_prod_threshold_adult.sql /app/iit_prod_threshold_adult.sql
COPY SQL/iit_prod_threshold_adult.sql /app/iit_prod_threshold_pediatric.sql
# now we also need to add the R code used here
# this R code actually runs the stored procedures for run_daily_stored_procedures.sh
# this is done in R so we can re-use the database settings for the API
COPY docker-resources/dailyStoredProcedures.R /app/dailyStoredProcedures.R
# plumber.R is the main app
COPY docker-resources/plumber.R /app/plumber.R
# EXPOSE is just documentation; by default, the API is run on port 8000
# In production, this port is not exposed, as we hit the API from inside the container
EXPOSE 8000
# setup the entrypoint
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
# this may not be necessary, but its left in to match the parent container defaults
CMD ["/app/plumber.R"]