-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
70 lines (50 loc) · 1.8 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
FROM trestletech/plumber
LABEL maintainer="George Kampolis <gkampolis@outlook.com>"
###########################################################
# Add mlr on top of plumber for Naive Bayes
###########################################################
# Add libxml2-dev for the `XML` package (line 26).
RUN apt-get update -qq && apt-get install -y libxml2-dev && apt-get clean -y
# Add "Depends" of mlr
RUN install2.r -e -s ParamHelpers
# Add "Imports" of mlr, this takes a while.
RUN install2.r -e -s \
BBmisc \
backports \
ggplot2 \
stringi \
checkmate \
data.table \
parallelMap \
survival \
XML
# Add mlr itself
RUN install2.r -e -s mlr
# Add e1071 required for Naive Bayes classifier
RUN install2.r -e -s e1071
###########################################################
# Copy API files
###########################################################
# Add main script to be plumbed
COPY mainAPI.R \
/home/docker/api/
# Add the contents of the `model` folder
COPY model/* \
/home/docker/api/model/
# Ensure permissions of user `docker`
RUN chown docker:docker /home/docker/*
# Designate which R script to plumb.
WORKDIR /home/docker/api
CMD ["mainAPI.R"]
###########################################################
# How To (when running locally)
###########################################################
# Run locally with: `docker run --rm --user docker -p 8000:8000 titanic_api` (defaults to `/api/mainAPI.R`)
# See results on http://localhost:8000/
# Example query:
# `http://localhost:8000/titanic?pClass=2&pSex=male&pAge=70&pFare=125&pFamily=0`
# Example response (JSON):
# [{"prob.FALSE":0.0479,"prob.TRUE":0.9521,"response":"TRUE"}]
# You can have a look around inside the image with
# `docker run -it --rm --entrypoint /bin/bash titanic_api`.
# Build with: `docker build -t titanic_api .` (Note the dot at the end)