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

Deployment Help for Brochure application #31

Open
Brabin3 opened this issue Jan 4, 2022 · 7 comments
Open

Deployment Help for Brochure application #31

Brabin3 opened this issue Jan 4, 2022 · 7 comments

Comments

@Brabin3
Copy link

Brabin3 commented Jan 4, 2022

I have built up a multi-page application using Brochure.
I tried to deploy it using Docker & ShinyProxy deployment model.
The app gets deployed and the first page alone loads.
All other pages are missing when deployed with ShinyProxy (404).

In shiny Proxy application.yml file,
container-cmd: ["R", "-e", "shiny::runApp('/root/euler')"]

When I tried to deploy the application without Brochure (i.e Single paged shiny app) then the deployment works.

Any help is greatly invited.

@ColinFay
Copy link
Owner

Hey,

Yeah there is an issue with the way shiny proxy works — it iframes the actual app so there might be an issue with that.

I will have a look and let you know

@Brabin3
Copy link
Author

Brabin3 commented Feb 26, 2022

Hey, Thank you!

Your help is greatly appreciated.

@jjfantini
Copy link

Has there been any progress made with using shinyProxy and Docker? I was looing to use this deployment avenue myself, @ColinFay @Brabin3

@ColinFay
Copy link
Owner

ColinFay commented Mar 3, 2022

Two q for @Brabin3 :

-> Do you have specified a basepath in your brochureApp ? by default brochure assumes that your app is at url/, but shinyproxy deploys at url/myapp
-> Do the link inside your app redirect to url/myapp/mypage or to url/mypage ?

@jjfantini I'll work on this, my only current issue is that it requires some time to have a shiny proxy running, a container with a brochure app, and all that is implied by that :)

@jjfantini
Copy link

@ColinFay that sounds great, I will try to flesh out issues here that I run into when deploying with this method, think it would be helpful for users down the road to have this one paved...looking forward to a fully isolated app environment that is isolated further with brochure -- the data flow design is much better when so explicit. Look forward to the journey ahead :) bear with me, v new to web dev

@jjfantini
Copy link

@ColinFay so the basepath argument should be url/myapp and the following brochurePages() should be href = 'myapp/page'?

@teofiln
Copy link

teofiln commented May 8, 2022

I have something similar on shinyapps.io, where the apps url is: username.shinyapps.io/app_name. Because the base url is /app_name, and not just /, the redirects also do not work out of the box.

I was able to get things working by:

  1. adding baseurl = app_name in run_app()
  2. converting all the redirect links from /pageX to /app_name/pageX

So now things work well on shinyapps.io, but not locally, as the local url does not have the /app_name suffix.

To fix this we can dynamically generate the redirect href based on getOption("baseurl"). Some function like:

#' make_href
#'
#' @description Add appropriate prefix to redirect link depending on context (option baseurl)
#' @param endpoint endpoint without leading `/`
#' @noRd
make_href <- function(endpoint) {
  baseurl <- getOption("baseurl")
  if (baseurl != "") {
    paste0("/", baseurl, "/", endpoint, sep = "")
  } else {
    paste0("/", endpoint, sep = "")
  }
}

Then, in /dev/run_dev.R we can set

options(baseurl = "")
> make_href("")
[1] "/"
> make_href("page2")
[1] "/page2"

# then run app should work with unprefixed hrefs
run_app()

In 'production' mode on shinyapps.io, we can add the baseurl option in app.R just before calling run_app() :

options(baseurl = "my_app")
> make_href("")
[1] "/my_app/"
> make_href("page2")
[1] "/my_app/page2"

# then run app should work with prefixed hrefs
run_app()

Maybe something similar will work in shinyProxy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants