Skip to content

Commit

Permalink
Merge pull request #14 from gvegayon/main
Browse files Browse the repository at this point in the history
Deployment with Docker container
  • Loading branch information
gvegayon authored May 1, 2024
2 parents 499a2cc + 82cb30f commit c18244c
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ README.Rmd
^CODE_OF_CONDUCT\.md$
^app\.R$
^rsconnect$
^app$
Dockerimage
19 changes: 9 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ on:
- main
jobs:
deploy:
runs-on: [macOS-latest, windows-latest, ubuntu-latest]
runs-on: [ubuntu-latest]
container:
image: gvegayon/epiworldrshiny:latest
steps:
- uses: actions/checkout@v2
- name: Set up R
uses: r-lib/actions/setup-r@v2
- name: Install dependencies
run: |
install.packages("remotes")
remotes::install_deps(dependencies = TRUE)

- name: Deploy
env:
RSHINYAPPSTOKEN: ${{ secrets.MYKEY }}
RSHINYAPPSEMAIL: ${{ secrets.MYEMAIL }}
SHINY_SECRET: ${{ secrets.SHINY_SECRET }}
SHINY_TOKEN: ${{ secrets.SHINY_TOKEN }}
SHINY_USER: ${{ secrets.SHINY_USER }}
run: |
rsconnect::deployApp(appDir = '~/Desktop/Research/epiworldRShiny')
make build install deploy
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/r.yml → .github/workflows/r.yml.old
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
error-on: '"warning"'

- uses: r-lib/actions/check-r-package@v2
if: ${{ matrix.config.os != 'ubuntu-latest' || matrix.config.r != 're;ease' }}
if: ${{ matrix.config.os != 'ubuntu-latest' || matrix.config.r != 'release' }}
with:
upload-snapshots: false
upload-results: false
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.Rproj.user
.Rhistory
.Rhistory
.secrets.R
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM rocker/tidyverse:4.3.3

# Installing only packages that are not already installed in the base image
RUN install2.r -s \
shinyjs \
utils \
shinydashboard \
DT \
ggplot2 \
epiworldR \
shinycssloaders \
plotly \
pkgload \
shiny


RUN install2.r -s rsconnect

CMD ["bash"]
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Get the version of the R package and save it
PKG_VERSION:=$(shell Rscript -e 'x<-readLines("DESCRIPTION");cat(gsub(".+[:]\\s*", "", x[grepl("^Vers", x)]))')
PKG_NAME := epiworldRShiny

# Capture the current directory
DIR_NAME:=$(shell basename `pwd`)
PKG_NAME:= epiworldRShiny

which:
@echo "PKG_VERSION: $(PKG_VERSION)"
Expand All @@ -10,7 +13,7 @@ docs:
Rscript --vanilla -e 'devtools::document()'

build:
cd .. && R CMD build $(PKG_NAME)
cd .. && R CMD build $(DIR_NAME)

install:
cd .. && R CMD INSTALL $(PKG_NAME)_$(PKG_VERSION).tar.gz
Expand All @@ -20,3 +23,20 @@ run:

check:
cd .. && R CMD check $(PKG_NAME)_$(PKG_VERSION).tar.gz

docker-build:
docker build -t gvegayon/epiworldrshiny .

docker-push:
docker push gvegayon/epiworldrshiny

docker-run:
docker run -i --rm -v$(PWD):/epiworld/ uofuepibio/epiworldrshiny


deploy:
Rscript --vanilla epishiny/deploy.R



.PHONY: docs build install run check docker-build
1 change: 1 addition & 0 deletions epishiny/app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
epiworldRShiny::run_app()
20 changes: 20 additions & 0 deletions epishiny/deploy.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
library(rsconnect)

rsconnect::setAccountInfo(
name = Sys.getenv("SHINY_USER"),
token = Sys.getenv("SHINY_TOKEN"),
secret = Sys.getenv("SHINY_SECRET")
)

cat("Listing the current directory and its contents\n")
cat(getwd(), "\n")
list.files() |> cat("\n")

rsconnect::deployApp(
appDir = file.path(getwd(), "epishiny"),
appName = "epishiny",
# appId = Sys.getenv("SHINY_APP_ID"),
forceUpdate = TRUE,
account = Sys.getenv("SHINY_USER"),
logLevel = "verbose"
)

0 comments on commit c18244c

Please sign in to comment.