-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/API' into develop
- Loading branch information
Showing
5 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM rocker/r-ver | ||
|
||
# FROM rstudio/plumber | ||
|
||
# sysreqs - pak::pkg_system_requirements("plumber", "ubuntu", "20.04") | ||
RUN apt-get install -y libcurl4-openssl-dev \ | ||
apt-get install -y libssl-dev \ | ||
apt-get install -y libsodium-dev \ | ||
apt-get install -y libicu-dev \ | ||
apt-get install -y make \ | ||
apt-get install -y zlib1g-dev | ||
|
||
# R packages | ||
RUN R -e "install.packages('plumber')" | ||
RUN R -e "install.packages('remotes')" | ||
RUN R -e "remotes::install_github('jimbrig/lossrx')" | ||
|
||
# Copy API | ||
COPY plumber.R / | ||
|
||
# Expose Port 80 to Traffic | ||
EXPOSE 80 | ||
|
||
# Entrypoint | ||
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb('plumber.R'); pr$run(host='0.0.0.0', port=80)"] |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# This is a Plumber API. You can run the API by clicking | ||
# the 'Run API' button above. | ||
# | ||
# Find out more about building APIs with Plumber here: | ||
# | ||
# https://www.rplumber.io/ | ||
# | ||
|
||
library(plumber) | ||
|
||
#* @apiTitle Loss Reserving API | ||
#* @apiDescription An Actuarial API for dealing with Loss Reserving Data and Workflows. | ||
|
||
|
||
# Utility Endpoints ------------------------------------------------------- | ||
|
||
#* Echo back the input | ||
#* @param msg The message to echo | ||
#* @get /echo | ||
function(msg = "") { | ||
list(msg = paste0("The message is: '", msg, "'")) | ||
} | ||
|
||
# Programmatically alter your API | ||
#* @plumber | ||
function(pr) { | ||
pr %>% | ||
# Overwrite the default serializer to return unboxed JSON | ||
pr_set_serializer(serializer_unboxed_json()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
docker build -t lossreservingapi:latest . | ||
docker run -p 80:80 -d lossreservingapi:latest |