返回技能列表

deploy-shinyproxy

pjt222
更新于 Yesterday
2 次查看
17
2
17
在 GitHub 上查看
文档aidata

关于

This skill deploys ShinyProxy to host multiple containerized Shiny applications behind a single entry point. It handles Docker deployment, application configuration, authentication, and usage tracking. Use it when you need to manage multiple isolated Shiny apps with access control and scaling capabilities.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/deploy-shinyproxy

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

部署 ShinyProxy

部 ShinyProxy 以宿多容器化之 Shiny 應用,具認證與用量跟蹤。

用時

  • 於單入口宿多 Shiny 應用
  • 需各應用獨之認證與訪問控
  • 部 Shiny 應用為獨立 Docker 容器
  • 擴至單應用部署(shinyapps.io 或獨立 Docker)之上
  • 需用量析與審計日誌

  • 必要:一或多 Shiny 應用以部
  • 必要:已裝 Docker 之伺
  • 可選:認證供應者(LDAP、OpenID、社交)
  • 可選:域名與 SSL 證書
  • 可選:容器編排者(Docker 或 Kubernetes)

第一步:建 Shiny 應用 Docker 鏡像

各 Shiny 應用需其自鏡像。Shiny 應用之 Dockerfile 例:

FROM rocker/shiny:4.5.0

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

RUN R -e "install.packages(c('shiny', 'bslib', 'DT', 'dplyr'), \
    repos='https://cloud.r-project.org/')"

COPY app/ /srv/shiny-server/app/

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

USER shiny
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/srv/shiny-server/app', host='0.0.0.0', port=3838)"]

建並測各應用:

docker build -t myorg/dashboard:latest ./apps/dashboard/
docker run --rm -p 3838:3838 myorg/dashboard:latest

得: 各 Shiny 應用於其自容器獨立行。

第二步:配 ShinyProxy

application.yml

proxy:
  title: "Shiny Applications"
  port: 8080
  container-backend: docker
  docker:
    internal-networking: true
  authentication: simple
  admin-groups: admins

  users:
    - name: admin
      password: admin_password
      groups: admins
    - name: analyst
      password: analyst_password
      groups: users

  specs:
    - id: dashboard
      display-name: "Analytics Dashboard"
      description: "Interactive data analysis dashboard"
      container-image: myorg/dashboard:latest
      container-cmd: ["R", "-e", "shiny::runApp('/srv/shiny-server/app', host='0.0.0.0', port=3838)"]
      container-network: shinyproxy-net
      port: 3838
      access-groups: [admins, users]

    - id: report-builder
      display-name: "Report Builder"
      description: "Generate custom reports"
      container-image: myorg/report-builder:latest
      container-cmd: ["R", "-e", "shiny::runApp('/srv/shiny-server/app', host='0.0.0.0', port=3838)"]
      container-network: shinyproxy-net
      port: 3838
      access-groups: [admins]

logging:
  file:
    name: /opt/shinyproxy/log/shinyproxy.log

server:
  forward-headers-strategy: native

第三步:以 Docker Compose 部 ShinyProxy

docker-compose.yml

services:
  shinyproxy:
    image: openanalytics/shinyproxy:3.1.1
    container_name: shinyproxy
    ports:
      - "8080:8080"
    volumes:
      - ./application.yml:/opt/shinyproxy/application.yml:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - shinyproxy-logs:/opt/shinyproxy/log
    networks:
      - shinyproxy-net
    restart: unless-stopped

networks:
  shinyproxy-net:
    name: shinyproxy-net
    driver: bridge

volumes:
  shinyproxy-logs:
# Create the network first (ShinyProxy spawns containers on this network)
docker network create shinyproxy-net

# Start ShinyProxy
docker compose up -d

# Check logs
docker compose logs -f shinyproxy

得: ShinyProxy 於 8080 端啟,示登錄頁,列所配之應用。

敗則:docker compose logs shinyproxy。驗應用鏡像本地可得(docker images)。

第四步:配認證

簡(內建)

如第二步示之 authentication: simple 與行內用者。

LDAP

proxy:
  authentication: ldap
  ldap:
    url: ldap://ldap.example.com:389/dc=example,dc=com
    manager-dn: cn=admin,dc=example,dc=com
    manager-password: ldap_admin_password
    user-search-base: ou=users
    user-search-filter: (uid={0})
    group-search-base: ou=groups
    group-search-filter: (member={0})

OpenID Connect(Keycloak、Auth0 等)

proxy:
  authentication: openid
  openid:
    auth-url: https://auth.example.com/realms/myrealm/protocol/openid-connect/auth
    token-url: https://auth.example.com/realms/myrealm/protocol/openid-connect/token
    jwks-url: https://auth.example.com/realms/myrealm/protocol/openid-connect/certs
    client-id: shinyproxy
    client-secret: your_client_secret
    roles-claim: realm_access.roles

第五步:以 Nginx 加反向代理

於產,宜置 Nginx 於 ShinyProxy 前:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen 443 ssl;
    server_name shiny.example.com;

    ssl_certificate /etc/letsencrypt/live/shiny.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/shiny.example.com/privkey.pem;

    location / {
        proxy_pass http://shinyproxy:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 600s;
        proxy_buffering off;
    }
}

WebSocket 支持至要——ShinyProxy 與 Shiny 重用 WebSocket。

第六步:用量跟蹤

ShinyProxy 將用量事件記入日誌。欲結構化跟蹤,配 InfluxDB:

proxy:
  usage-stats-url: http://influxdb:8086/write?db=shinyproxy
  usage-stats-username: shinyproxy
  usage-stats-password: stats_password

於 compose 棧加 InfluxDB:

services:
  influxdb:
    image: influxdb:1.8
    environment:
      INFLUXDB_DB: shinyproxy
      INFLUXDB_ADMIN_USER: admin
      INFLUXDB_ADMIN_PASSWORD: admin_password
    volumes:
      - influxdata:/var/lib/influxdb
    networks:
      - shinyproxy-net

volumes:
  influxdata:

第七步:應用資源限

specs:
  - id: dashboard
    container-image: myorg/dashboard:latest
    container-memory-limit: 1g
    container-cpu-limit: 1.0
    max-instances: 5
    container-env:
      R_MAX_MEM_SIZE: 768m

第八步:驗部署

# Check ShinyProxy health
curl -s http://localhost:8080/actuator/health

# Test login
curl -s -c cookies.txt -d "username=admin&password=admin_password" \
  http://localhost:8080/login

# List apps via API
curl -s -b cookies.txt http://localhost:8080/api/proxyspec

得: 健端返 UP。登錄成。應用於獨容器啟。

  • ShinyProxy 啟且示登錄頁
  • 認證為諸所配用者可行
  • 各 Shiny 應用於其自容器啟
  • WebSocket 連可(Shiny 反應性可行)
  • 訪問組正限應用可見
  • 用者離時容器清理可行
  • 日誌捕用量事件

  • Docker socket 權限:ShinyProxy 需 Docker socket 以啟容器。以 docker 組之用者行,或掛 socket。
  • 網絡不合:應用容器宜與 ShinyProxy 同 Docker 網(specs 中 container-network 宜合)。
  • WebSocket 代理:ShinyProxy 前之 Nginx 或他代理須轉 WebSocket 升級頭。
  • 鏡像不見:應用鏡像宜於 Docker 主預裝或預建,而後 ShinyProxy 始用。
  • 容器清理:若 ShinyProxy 崩,孤兒應用容器或留。以 docker ps 察且清之。
  • 內存限:Shiny 應用或耗大內存。設 container-memory-limit 以防一應用餓他者。

Related Skills

  • deploy-shiny-app - 單應用部至 shinyapps.io、Posit Connect 或 Docker
  • configure-reverse-proxy - 反向代理模式含 WebSocket 代理
  • create-dockerfile - 通用應用鏡像 Dockerfile 建
  • create-r-dockerfile - 用 rocker 鏡之 R 特定 Dockerfile

GitHub 仓库

pjt222/agent-almanac
路径: i18n/wenyan/skills/deploy-shinyproxy
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

railway-docs

文档

Railway Docs Skill可实时获取最新的Railway官方文档,确保回答的准确性。当开发者询问Railway功能特性、工作原理或分享docs.railway.com链接时,应优先使用此技能。它通过专门的LLM优化文档源提供最新信息,避免依赖过时记忆来回答技术问题。

查看技能

n8n-code-python

文档

该Skill为在n8n平台的Python代码节点中编写代码提供专家指导,特别适用于需要使用_input/_json/_node语法、Python标准库或了解n8n中Python限制的场景。它强调JavaScript应作为首选方案,仅当需要特定Python功能或对Python语法更熟悉时才使用Python。Skill提供了快速入门模板和关键注意事项,帮助开发者在n8n中高效编写Python代码。

查看技能

archon

文档

Archon Skill为开发者提供了基于RAG的语义搜索和项目任务管理功能,可通过REST API访问知识库。它支持文档搜索、网站爬取、文件上传和版本控制,适用于技术文档查询和项目管理场景。首次使用时需要配置Archon主机地址,建议在处理外部文档时优先使用该Skill。

查看技能

n8n-code-javascript

文档

这个Skill为n8n工作流中的JavaScript代码节点提供专业指导,涵盖数据处理、HTTP请求和日期操作等核心场景。它详细解释了如何正确使用n8n特有的`$input`/`$json`语法、`$helpers`工具以及DateTime对象,并包含关键的错误排查和模式选择建议。开发者通过该Skill能快速掌握Code节点的正确返回格式、数据访问方法和常见陷阱解决方案。

查看技能