Deploy R Shiny Apps with Google Cloud Run

useR! 2026 Conference

Alfredo Hernandez Sanchez

Vilnius University

2026-07-08

Follow the Slides

What is Google Cloud Run?


  • Google Cloud Run is a managed service for running containerized (e.g. Docker) applications without having to manage a server.

  • It handles the infrastructure around the app but lets us define the app, packages, container, memory, CPU, and access settings.

flowchart TD
  A[Shiny app] --> B[Docker container]
  B --> C[Cloud Run service]
  C --> D[Public URL]
  C --> E[Logs and revisions]
  C --> F[Scaling]

Google Cloud Key Elements

  • Project: the workspace where Google Cloud resources live.

  • Console: the browser interface for managing Google Cloud.

  • Cloud Run: the service that runs our Shiny app as a containerized web app.

  • Cloud Build and Artifact Registry: the services that build and store the container image before Cloud Run runs it.

Deployment Essentials

Checklist:

  • a Google Cloud account and a project
  • billing enabled for that project
  • the Cloud Run API enabled
  • the Cloud Build API enabled
  • the Artifact Registry API enabled
  • an app folder with app.R and Dockerfile

Workflow:


Shiny app files → Dockerfile → Cloud Build → Artifact Registry → Cloud Run service → public URL

What is Docker?

Docker packages an app with everything it needs to run. For Shiny:

  • App code,
  • R version,
  • R packages,
  • System libraries,
  • Command start up


flowchart TD
  A[Shiny app] --> E[Docker image]
  B[R packages] --> E
  C[System libraries] --> E
  D[Startup command] --> E
  E --> F[Container]
  F --> G[Running dashboard]

A minimal Dockerfile for Shiny


FROM rocker/shiny:4.4.0

USER root

RUN install2.r --error --skipinstalled --ncpus -1 \
    palmerpenguins \
    dplyr \
    ggplot2 \
    DT

WORKDIR /srv/shiny-server

COPY . /srv/shiny-server

RUN chown -R shiny:shiny /srv/shiny-server

ENV PORT=8080
EXPOSE 8080

USER shiny

CMD ["R", "-e", "shiny::runApp('/srv/shiny-server', host='0.0.0.0', port=as.numeric(Sys.getenv('PORT', '8080')))"]

The Dockerfile

  • FROM rocker/shiny:4.4.0 chooses the starting environment, here an image that already contains R and Shiny.

  • RUN install2.r ... installs the R packages the app needs.

  • WORKDIR /srv/shiny-server and COPY . /srv/shiny-server create the app folder inside the container and copy your local files into it.

  • ENV PORT=8080 and EXPOSE 8080 sets the port the app will use, should match the service.

  • CMD ["R", "-e", "..."] tells the container what to do when it starts (e.g. run the Shiny app)

Why Shiny on Cloud Run?

  • Closer to production cloud workflows: Docker logic can be reused for Shiny apps, APIs, Python services, background jobs, or other web apps.

  • Fine-grained resource control: adjust CPU, memory, concurrency, minimum instances, and maximum instances instead of buying into a fixed publishing platform.

  • More flexible runtime environment: you can include system libraries, non-R tools, Python, command-line utilities, or unusual package requirements.

Walkthrough

Cheatsheet

Thank you for your attention!

About the FIRSA Project

Disclaimer:

This project has received funding from the European Union Marie Skłodowska-Curie Postdoctoral Fellowships / ERA Fellowships action under grant agreement No. 101180601 under the title: Understanding FinTech Regulatory Sandbox Development in Europe (FIRSA).

Learn more at the project website.

Logo