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

How to deploy ga_model_shiny apps? #367

Open
MarkEdmondson1234 opened this issue Feb 12, 2021 · 2 comments
Open

How to deploy ga_model_shiny apps? #367

MarkEdmondson1234 opened this issue Feb 12, 2021 · 2 comments
Assignees

Comments

@MarkEdmondson1234
Copy link
Collaborator

MarkEdmondson1234 commented Feb 12, 2021

Can write the files to the local folder, but how to deploy it to shinyapps.io etc with:

shinyApp(gar_shiny_ui(ui, login_ui = silent_auth), server) etc. ?

Its ok for Shiny single file app.R which includes it

@MarkEdmondson1234
Copy link
Collaborator Author

MarkEdmondson1234 commented Mar 5, 2021

Shinyapps.io deployments working

A googleCloudRunner example needs a Docker with at least googleAnalyticsR and shiny installed.

deployed_url can only be seen if domain has been mapped or after first deployment e.g. deployed_url="https://cloudrun-test-ewjogewawq-ew.a.run.app"

ga_model_shiny(
    ga_model_example("decomp_ga.gamr"), 
    auth_dropdown = "universal",
    template = ga_model_shiny_template("basic_app"),
    deployed_url="https://cloudrun-test-ewjogewawq-ew.a.run.app",
    local_folder = "cloudrun_test")

Copy in Dockerfile and shiny-customised.config

FROM rocker/shiny

# install googleanalyticsr
RUN install2.r --error \ 
    -r 'http://cran.rstudio.com' \
    googleAnalyticsR \
    ## install Github packages
    && installGithub.r MarkEdmondson1234/googleAnalyticsR \
    ## clean up
    && rm -rf /tmp/downloaded_packages/ /tmp/*.rds

COPY app.R /srv/shiny-server/app.R
COPY app/ /srv/shiny-server/app/
COPY shiny-customised.config /etc/shiny-server/shiny-server.conf

EXPOSE 8080

USER shiny

# avoid s6 initialization
# see https://github.com/rocker-org/shiny/issues/79
CMD ["/usr/bin/shiny-server"]

Deploy

library(googleCloudRunner)
cr_deploy_run("cloudrun_test/",
              remote = "cloudrun_test",
              tag = c("latest","$BUILD_ID"),
              max_instances = 1, # required for shiny
              concurrency = 80, 
              launch_browser = FALSE)

@MarkEdmondson1234
Copy link
Collaborator Author

Cloud Run working now, included the Docker image from above to make it easier to use which will be included when writing to the local folder, gcr.io/gcer-public/googleanalyticsr-shiny-cloudrun

# from rocker/shiny with googleAnalyticsR installed & configued for Cloud Run
FROM gcr.io/gcer-public/googleanalyticsr-shiny-cloudrun

# add any dependencies for your app here
# RUN install2.r --error -r 'http://cran.rstudio.com' googleAnalyticsR
# RUN installGithub.r MarkEdmondson1234/googleAnalyticsR

COPY . /srv/shiny-server/

MarkEdmondson1234 added a commit that referenced this issue Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant