MCP HubMCP Hub
Volver a habilidades

deploy-shiny-app

pjt222
Actualizado 2 days ago
8 vistas
17
2
17
Ver en GitHub
Metaaiautomation

Acerca de

Esta habilidad despliega aplicaciones Shiny en shinyapps.io, Posit Connect o contenedores Docker. Maneja la configuración de rsconnect, la generación de manifiestos, la creación de Dockerfiles y la verificación del despliegue. Úsala al publicar aplicaciones para usuarios, al pasar del desarrollo local al alojamiento o al configurar canalizaciones de despliegue automatizadas.

Instalación rápida

Claude Code

Recomendado
Principal
npx skills add pjt222/agent-almanac -a claude-code
Comando PluginAlternativo
/plugin add https://github.com/pjt222/agent-almanac
Git CloneAlternativo
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/deploy-shiny-app

Copia y pega este comando en Claude Code para instalar esta habilidad

Documentación

Deploy Shiny App

Deploy a Shiny application to shinyapps.io, Posit Connect, or a Docker container.

When to Use

  • Publishing a Shiny app for external or internal users
  • Moving from local development to a hosted environment
  • Containerizing a Shiny app for Kubernetes or Docker deployment
  • Setting up automated deployment pipelines

Inputs

  • Required: Path to the Shiny application
  • Required: Deployment target (shinyapps.io, Posit Connect, or Docker)
  • Optional: Account name and token (for shinyapps.io/Connect)
  • Optional: Instance size preference
  • Optional: Custom domain or URL path

Procedure

Step 1: Prepare the Application

Ensure the app is self-contained and deployable:

# Check for missing dependencies
rsconnect::appDependencies("path/to/app")

# For golem apps, ensure DESCRIPTION lists all Imports
devtools::check()

# Verify the app runs cleanly
shiny::runApp("path/to/app")

Verify these files exist:

  • app.R (or ui.R + server.R)
  • renv.lock (recommended for reproducible deployments)
  • .Rprofile does NOT call mcptools::mcp_session() in production

Got: App runs locally without errors and all dependencies are captured.

If fail: If appDependencies() reports missing packages, install them and update renv.lock. If the app uses system libraries (e.g., gdal, curl), note them for the Docker path.

Step 2a: Deploy to shinyapps.io

# One-time account setup
rsconnect::setAccountInfo(
  name = "your-account",
  token = Sys.getenv("SHINYAPPS_TOKEN"),
  secret = Sys.getenv("SHINYAPPS_SECRET")
)

# Deploy
rsconnect::deployApp(
  appDir = "path/to/app",
  appName = "my-app",
  appTitle = "My Application",
  account = "your-account",
  forceUpdate = TRUE
)

Store credentials in .Renviron (never in code):

# .Renviron
SHINYAPPS_TOKEN=your_token_here
SHINYAPPS_SECRET=your_secret_here

Got: App deployed and accessible at https://your-account.shinyapps.io/my-app/.

If fail: If authentication fails, regenerate tokens at shinyapps.io dashboard > Account > Tokens. If package installation fails on the server, check that all packages are available on CRAN — shinyapps.io cannot install from GitHub by default.

Step 2b: Deploy to Posit Connect

# Register server (one-time)
rsconnect::addServer(
  url = "https://connect.example.com",
  name = "production"
)

# Authenticate (one-time)
rsconnect::connectApiUser(
  account = "your-username",
  server = "production",
  apiKey = Sys.getenv("CONNECT_API_KEY")
)

# Deploy
rsconnect::deployApp(
  appDir = "path/to/app",
  appName = "my-app",
  server = "production",
  account = "your-username"
)

Got: App deployed and accessible on the Posit Connect instance.

If fail: If the server rejects the connection, verify the API key and server URL. If packages fail to install, check that Connect has access to the required repositories (CRAN, internal CRAN-like repos).

Step 2c: Deploy with Docker

Create a Dockerfile:

FROM rocker/shiny-verse:4.4.0

# Install system dependencies
RUN apt-get update && apt-get install -y \
    libcurl4-openssl-dev \
    libssl-dev \
    libxml2-dev \
    && rm -rf /var/lib/apt/lists/*

# Install R packages
RUN R -e "install.packages(c('shiny', 'bslib', 'DT', 'plotly'))"

# Copy app
COPY . /srv/shiny-server/myapp/

# Configure Shiny Server
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf

# Expose port
EXPOSE 3838

# Run
CMD ["/usr/bin/shiny-server"]

Create shiny-server.conf:

run_as shiny;

server {
  listen 3838;

  location / {
    site_dir /srv/shiny-server/myapp;
    log_dir /var/log/shiny-server;
    directory_index on;
  }
}

Build and run:

docker build -t myapp:latest .
docker run -p 3838:3838 myapp:latest

Got: App accessible at http://localhost:3838.

If fail: If the build fails on package installation, add missing system libraries to the apt-get install line. If the app doesn't load, check Shiny Server logs: docker exec <container> cat /var/log/shiny-server/*.log.

Step 3: Verify Deployment

# Check the deployed URL responds
response <- httr::GET("https://your-app-url/")
httr::status_code(response)  # Should be 200

# For Docker
response <- httr::GET("http://localhost:3838/")
httr::status_code(response)

Manual verification checklist:

  1. App loads without errors
  2. All interactive elements respond
  3. Data connections work in the deployed environment
  4. Authentication/authorization works (if applicable)

Got: App responds with HTTP 200 and all features work.

If fail: Check server logs for the specific deployment platform. Common issues: environment variables not set in production, database connections using localhost instead of production URLs, or file paths that only exist locally.

Step 4: Configure Monitoring (Optional)

shinyapps.io

Monitor via the dashboard at https://www.shinyapps.io/admin/#/applications.

Posit Connect

# Check deployment status via API
connectapi::connect(
  server = "https://connect.example.com",
  api_key = Sys.getenv("CONNECT_API_KEY")
)

Docker

Add health check to Dockerfile:

HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
  CMD curl -f http://localhost:3838/ || exit 1

Got: Monitoring configured for the deployment target.

If fail: If health checks fail intermittently, increase timeout values. Shiny apps can be slow to respond during initial load.

Validation

  • App deploys without errors
  • Deployed URL responds with HTTP 200
  • All interactive features work in production
  • Environment variables/secrets are configured (not hardcoded)
  • Credentials stored in .Renviron or CI secrets, not in code
  • renv.lock committed for reproducible dependency resolution

Pitfalls

  • Hardcoded file paths: Replace absolute paths with system.file() (for package data) or environment variables (for external resources).
  • Development-only dependencies: Don't deploy .Rprofile that loads mcptools::mcp_session() or devtools. Use conditional loading or separate profiles.
  • Missing system libraries in Docker: R packages like sf, curl, and xml2 need system libraries. Add them to the Dockerfile's apt-get install.
  • CRAN-only packages on shinyapps.io: shinyapps.io only installs from CRAN by default. GitHub-only packages need the remotes package and explicit installation in the deployment.
  • Forgotten environment variables: Database credentials, API keys, and other secrets must be configured in the deployment environment separately from code.

Related Skills

  • scaffold-shiny-app — create app structure before deployment
  • create-r-dockerfile — detailed Docker configuration for R projects
  • setup-docker-compose — multi-container setups for Shiny with databases
  • setup-github-actions-ci — CI/CD including automated deployment
  • optimize-shiny-performance — performance tuning before deploying to production

Repositorio GitHub

pjt222/agent-almanac
Ruta: i18n/caveman-lite/skills/deploy-shiny-app
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

Habilidades relacionadas

content-collections

Meta

Esta habilidad proporciona una configuración probada en producción para Content Collections, una herramienta centrada en TypeScript que transforma archivos Markdown/MDX en colecciones de datos con tipado seguro mediante validación Zod. Úsala al construir blogs, sitios de documentación o aplicaciones Vite + React con mucho contenido para garantizar seguridad de tipos y validación automática de contenido. Abarca todo, desde la configuración del plugin de Vite y compilación MDX hasta la optimización de despliegue y validación de esquemas.

Ver habilidad

polymarket

Meta

Esta habilidad permite a los desarrolladores crear aplicaciones con la plataforma de mercados de predicción Polymarket, incluyendo la integración de API para operaciones y datos de mercado. También proporciona transmisión de datos en tiempo real a través de WebSocket para monitorear operaciones en vivo y actividad del mercado. Úsela para implementar estrategias de trading o crear herramientas que procesen actualizaciones de mercado en tiempo real.

Ver habilidad

creating-opencode-plugins

Meta

Esta habilidad ayuda a los desarrolladores a crear complementos de OpenCode que se conectan a más de 25 tipos de eventos, como comandos, archivos y operaciones LSP. Proporciona la estructura del complemento, las especificaciones de la API de eventos y los patrones de implementación para módulos en JavaScript/TypeScript. Úsala cuando necesites interceptar, monitorear o extender el ciclo de vida del asistente de IA de OpenCode con lógica personalizada basada en eventos.

Ver habilidad

sglang

Meta

SGLang es un framework de alto rendimiento para el servicio de LLM que se especializa en generación rápida y estructurada para JSON, expresiones regulares y flujos de trabajo de agentes utilizando su caché de prefijos RadixAttention. Ofrece una inferencia significativamente más rápida, especialmente para tareas con prefijos repetidos, lo que lo hace ideal para salidas complejas y estructuradas, y conversaciones multiturno. Elige SGLang sobre alternativas como vLLM cuando necesites decodificación restringida o estés construyendo aplicaciones con uso extensivo de prefijos compartidos.

Ver habilidad