Compare commits

...

4 Commits

Author SHA1 Message Date
Minghe Huang
be9472a53c clean a little 2017-11-25 21:42:28 +08:00
Minghe Huang
f895b2151f fix installation of dependencies issue 2017-11-25 20:30:13 +08:00
Minghe Huang
7af6a9b311 refactor and add testing 2017-11-24 12:23:04 +08:00
Minghe Huang
dbefe38dd6 init R support 2017-11-23 01:41:12 +08:00
5 changed files with 26 additions and 1 deletions

View File

@@ -44,9 +44,10 @@ jobs:
fx up examples/functions/func.go >> deploy.log
fx up examples/functions/func.php >> deploy.log
fx up examples/functions/func.jl >> deploy.log
fx up examples/functions/func.R >> deploy.log
cat server_output.log
cat deploy.log;
cat deploy.log | grep 'Succed: 1' | wc -l | grep 6
cat deploy.log | grep 'Succed: 1' | wc -l | grep 7
deployment:
production:

9
images/R/Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM r-base
COPY . /usr/local/src/fx
WORKDIR /usr/local/src/fx
RUN R -f packages.R
EXPOSE 3000
CMD ["Rscript", "app.R"]

11
images/R/app.R Normal file
View File

@@ -0,0 +1,11 @@
library(jug)
library(jsonlite)
source('./fx.R')
jug() %>%
post("/", function(req, res, err) {
input <- fromJSON(req$body)
fx(input)
}) %>%
simple_error_handler_json() %>%
serve_it(port = 3000)

3
images/R/fx.R Normal file
View File

@@ -0,0 +1,3 @@
fx <- function(input) {
return (strtoi(input$a) + strtoi(input$b))
}

1
images/R/packages.R Normal file
View File

@@ -0,0 +1 @@
install.packages(c("jug", "jsonlite"), repos="http://cran.us.r-project.org", dependencies=TRUE)