Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Docker files #589

Merged
merged 16 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Docker

on:
push:
branches:
- "master"
schedule:
- cron: '0 0 1 * *' # first of every month


jobs:
docker:
name: ${{ matrix.config.tags }}
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
r_version:
- "latest"

config:
- name: CRAN
# always overwrite the latest version with the CRAN version
tags: "v0.4.6,latest"
ref: "v0.4.6"

- name: GitHub
# 'next' tag signifies the _next_ release
tags: "next"
ref: "master"


steps:
- uses: actions/checkout@master

# https://github.com/marketplace/actions/publish-docker
- name: rstudio/plumber
uses: elgohr/Publish-Docker-Github-Action@2.18
with:
name: rstudio/plumber
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
cache: false
workdir: "."
buildargs: "R_VERSION=${{ matrix.r_version }},PLUMBER_REF=${{ matrix.config.ref }}${{ matrix.config.extra_buildargs }}"
tags: ${{ matrix.config.tags }}
60 changes: 52 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,60 @@
FROM rocker/r-base
MAINTAINER Jeff Allen <docker@trestletech.com>

RUN apt-get update -qq && apt-get install -y \
ARG R_VERSION=latest

FROM rocker/r-ver:${R_VERSION}
LABEL maintainer="barret@rstudio.com"

ARG PLUMBER_REF=master

# BEGIN rstudio/plumber layers
RUN apt-get update -qq && apt-get install -y --no-install-recommends \
git-core \
libssl-dev \
libcurl4-gnutls-dev \
libsodium-dev
curl \
libsodium-dev \
libxml2-dev

RUN install2.r remotes

## RUN R -e 'install.packages(c("remotes"))'
## RUN R -e 'remotes::install_github("rstudio/plumber")'
RUN install2.r plumber
## Remove this comment to always bust the Docker cache at this step
## https://stackoverflow.com/a/55621942/591574
#ADD https://github.com/rstudio/plumber/commits/ _docker_cache

RUN Rscript -e "remotes::install_github('rstudio/plumber@${PLUMBER_REF}')"

EXPOSE 8000
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8000)"]

ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(rev(commandArgs())[1]); pr$run(host='0.0.0.0', port=8000, swagger=TRUE)"]

CMD ["/usr/local/lib/R/site-library/plumber/examples/04-mean-sum/plumber.R"]

# EOF rstudio/plumber layers

# README:

# Usage (adjust the tags/versions according to your preferences):

# build docker file
# docker build --build-arg R_VERSION=4.0.2 -t rstudio/plumber:latest .
# run with defaults
# docker run -it -p 8000:8000 --rm --name plumber rstudio/plumber:latest
# open in browser
# firefox http://localhost:8000/__swagger__/ &

# to run with your own api - mount your plumber.R file into the container like so:
# docker run -it -p 8000:8000 --rm -v ~/R/x86_64-pc-linux-gnu-library/4.0/plumber/examples/10-welcome/plumber.R:/api/plumber.R:ro --name myapi rstudio/plumber:latest /api/plumber.R
# then browse with
# curl http://localhost:8000/


# Extend the rstudio/plumber:TAG Dockerfile / build your own custom image adding debian packages and your own api:

## ./Dockerfile
# FROM rstudio/plumber:latest
# RUN apt-get update -qq && apt-get install -y \
# [list-your-debian-packages-here]
# # add app files from host's present working dir
# COPY . /api
# # set default startup command to run the app's "plumber.R" file
# CMD ["/api/plumber.R"]
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ plumber 1.0.0

### Minor new features and improvements

* Updated Docker files. New Docker repo is now [`rstudio/plumber`](https://hub.docker.com/r/rstudio/plumber/tags). Updates heavily inspired from @mskyttner (#459). (#589)

* Support HTTP 405 Code. (@meztez, #554)

* Attached the router to the incoming request object at `req$pr`. (@meztez, #554)
Expand Down
34 changes: 0 additions & 34 deletions inst/check/Dockerfile

This file was deleted.

30 changes: 0 additions & 30 deletions inst/check/Dockerfile-v0.5.0

This file was deleted.

5 changes: 2 additions & 3 deletions inst/examples/03-github/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM trestletech/plumber
MAINTAINER Jeff Allen <docker@trestletech.com>
FROM rstudio/plumber:next

COPY github-key.txt /github-key

CMD ["/examples/03-github/github.R"]
CMD ["/usr/local/lib/R/site-library/plumber/examples/03-github/plumber.R"]
8 changes: 5 additions & 3 deletions inst/examples/06-sessions/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM trestletech/plumber
MAINTAINER Jeff Allen <docker@trestletech.com>
FROM rstudio/plumber:next

ENTRYPOINT R -e "pr <- plumber::plumb('/examples/06-sessions/sessions.R'); pr\$registerHooks(plumber::sessionCookie('secret', 'cookieName', path='/')); pr\$run(host='0.0.0.0', port=8000)"
ENTRYPOINT R \
-e "pr <- plumber::plumb(system.file('examples/06-sessions/plumber.R', package = 'plumber'))" \
-e "pr\$registerHooks(plumber::sessionCookie('pleasechangeme', 'cookieName'))" \
-e "pr\$run(host='0.0.0.0', port=8000)"
5 changes: 2 additions & 3 deletions inst/examples/07-mailgun/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM trestletech/plumber
MAINTAINER Jeff Allen <docker@trestletech.com>
FROM rstudio/plumber:next

RUN R -e "install.packages('htmltools')"

CMD ["/examples/07-mailgun/mailgun.R"]
CMD ["/usr/local/lib/R/site-library/plumber/examples/07-mailgun/plumber.R"]
6 changes: 0 additions & 6 deletions scripts/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
1. `devtools::release()`,
* (don't actually release in the last step)
* DON'T LIE!!
1. Run the docker image in inst/check on the release candidate. Note that you will need to change the CMD to checkout the release branch so you're testing it, not master.
1. ```{bash}
cd inst/check
docker build -t plumber_docker .
docker run plumber_docker
```


## Release Steps
Expand Down