惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
T
Threatpost
G
Google Developers Blog
T
Threat Research - Cisco Blogs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
The Exploit Database - CXSecurity.com
H
Heimdal Security Blog
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
T
The Blog of Author Tim Ferriss
Know Your Adversary
Know Your Adversary
Hacker News: Ask HN
Hacker News: Ask HN
www.infosecurity-magazine.com
www.infosecurity-magazine.com
S
Schneier on Security
B
Blog
V2EX - 技术
V2EX - 技术
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
W
WeLiveSecurity
C
Cybersecurity and Infrastructure Security Agency CISA
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Y
Y Combinator Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
Schneier on Security
Schneier on Security
F
Fortinet All Blogs
N
News | PayPal Newsroom
Attack and Defense Labs
Attack and Defense Labs
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
S
Security @ Cisco Blogs
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
Project Zero
Project Zero
I
Intezer
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - Franky
SecWiki News
SecWiki News
Martin Fowler
Martin Fowler

Yorksite

Plog006:Pebble Time 2 到了! · Plog Plog005:忙碌的六月 · Plog Plog004:好吃好吃 · Plog Plog003:Until Then · Plog Plog002:春天花会开 · Plog Plog001:让人疲惫的AI与在战锤世界中仰泳,赞美欧姆尼赛亚? · Plog rhaeTree:一个基于 Rust 的进化树可视化编辑工具 · Articles 我的键盘快捷键们 · Articles 迟到的2025年度数码产品总结 · Articles 关于我和这个博客 · Info 买了一只十多年前的老 Pebble · Articles 盘点一下今年让我上头的那些游戏 · Articles 【吃了啥】新利查西菜馆 · Articles 根据Zotero数据库追踪新发表文献 · Articles 解决远程服务器上Singularity联网问题 · Articles 又是一个Mac软件列表 · Articles Vita3K存档转移到PSV实机 · Articles SnapGene创建多外显子基因结构 · Articles Rstudio也能用GitHub Copilot了 · Articles 双十一买了啥 · Articles 文献一团乱麻?试试PARA管理方法 · Articles 点名的风还是吹到了Blog · Articles 从Raindrop迁移到了Anybox · Articles 数据可视化——基本图形元素及其应用 · Articles 单变量异常值检测方法 · Articles 复现一张相关性图 · Articles 【读文献】单细胞分析最佳实践 · Articles 部署预印本追踪 TRxiv 到 Github Action · Articles Hello, again · Articles 1 dataset 100 visualizations 中有意思的可视化 · Articles 论文可视化配色简易指南 · Articles Karabiner 助力,让你的键盘操作快人一步 · Articles 我的植物组学数据库合集 Ver.20220528 · Articles 利用 n8n 打造飞书 RSS 推送机器人 · Articles 「#」的前世今生 · Articles 克服低效率恐惧,回归健康生活 · Articles 科研论文作图基本知识 · Articles 为什么我们不喜欢学习 · Articles
Docker 打包 Shiny App · Articles
2023-03-28 · via Yorksite

Published Mar 28, 2023

2 minutes read

文件准备

将Shiny用到的server.Rui.R一起放在app文件夹中

./app:
server.R ui.R

写个Dockerfile,把用到的包都写在 install.r 后面

FROM rocker/r-base:latest
LABEL maintainer="email <example@mail.com>"
RUN apt-get update && apt-get install -y --no-install-recommends \
    sudo \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \
    && rm -rf /var/lib/apt/lists/*
RUN install.r shiny shinyBS dplyr stringr
RUN echo "local(options(shiny.port = 3838, shiny.host = '0.0.0.0'))" > /usr/lib/R/etc/Rprofile.site
RUN addgroup --system app \
    && adduser --system --ingroup app app
WORKDIR /home/app
COPY app .
RUN chown app:app -R /home/app
USER app
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/home/app')"]

按以下方式进行构建

# name of the image
export IMAGE="yorks0n/trxiv_shiny"
 
# build image
docker build -t $IMAGE .
 
# run and test locally
docker run -p 8080:3838 $IMAGE

居然就行了!

部署在 Railway 上

# 安装
brew install railway
 
# 登录
railway login

创建一个项目,并输入项目名称

 railway init
> Project Name TRxiv_shiny
Created project TRxiv_shiny on Personal

虽然当前目录下有个 Dockerfile 了,但是这 XX 的 railway 部署时候端口和默认 docker 的不太一样,或者我没找到哪里设置,所以如果要部署在 railway 上,还需要改一下 Dockerfile。虽然在这指定了ENV PORT=3838,但实际上 railway 每次开的端口都不太一样,所以标准 docker 的写法不太行。

FROM rocker/r-base:latest
LABEL maintainer="Yorkson <yorks0n@qq.com>"
RUN apt-get update && apt-get install -y --no-install-recommends \
    sudo \
    libcurl4-gnutls-dev \
    libcairo2-dev \
    libxt-dev \
    libssl-dev \
    libssh2-1-dev \
    && rm -rf /var/lib/apt/lists/*
RUN install.r shiny shinyBS dplyr stringr
RUN addgroup --system app \
    && adduser --system --ingroup app app
WORKDIR /home/app
COPY app .
RUN chown app:app -R /home/app
USER app
EXPOSE 3838
ENV PORT=3838
# 研究后发现,这里以获取PORT的方式,才能在 Railway 中部署
CMD ["R", "-e", "shiny::runApp('/home/app', host = '0.0.0.0', port=as.numeric(Sys.getenv('PORT')))"]
railway up

参考资料

在Windows系统下,基于WLS从零开始部署我的 R shiny项目到 Docker 中,并将镜像发布到 Docker Hub(内附详细操作流程)_douerw的博客-CSDN博客

Dockerizing Shiny Applications

Dockerized Shiny Apps with Dependencies