Skip to content

Commit

Permalink
Merge pull request #74 from m-muecke/examples/plumber
Browse files Browse the repository at this point in the history
refactor: update plumber example
  • Loading branch information
gaborcsardi authored Jan 10, 2024
2 parents 8aec7af + 40ba54a commit 415cc43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
23 changes: 12 additions & 11 deletions examples/plumber/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

FROM rhub/r-minimal

RUN apk add --no-cache --update-cache \
--repository http://nl.alpinelinux.org/alpine/v3.11/main \
autoconf=2.69-r2 \
automake=1.16.1-r0 && \
# repeat autoconf and automake (under `-t`)
# to (auto)remove them after installation
installr -d \
-t "libsodium-dev curl-dev linux-headers autoconf automake" \
-a libsodium \
plumber
RUN installr -d \
-t "libsodium-dev curl-dev linux-headers" \
-a libsodium \
plumber

WORKDIR /app

COPY . .

EXPOSE 8000

ENTRYPOINT ["R", "-e", "pr <- plumber::plumb('plumber.R'); pr$run(host = '0.0.0.0', port = 8000)"]
10 changes: 10 additions & 0 deletions examples/plumber/plumber.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#* @get /mean
function(samples = 10) {
data <- rnorm(samples)
mean(data)
}

#* @post /sum
function(a, b) {
as.numeric(a) + as.numeric(b)
}

0 comments on commit 415cc43

Please sign in to comment.