使用 caddy 自动从 Git 拉取并使用 NPM 编译 (持续构建)

下载并安装caddy:

curl https://getcaddy.com | bash -s hook.service,http.authz,http.cgi,http.cors,http.filemanager,http.git,http.hugo,http.login,http.minify,http.proxyprotocol,http.realip

安装为服务

caddy -service install -conf /etc/Caddyfile

参考修改/etc/Caddyfile

demo.com:80 {
    root /home/wwwroot/demo/dist
    git {
    repo git@git.oschina.net:demo/xxxx.git
        path /home/wwwroot/demo
        key /root/.ssh/id_rsa
        then npm install
        then npm run build
        hook /webhook ibenchu
        hook_type generic
    }
    gzip
    # log /var/log/caddy/access.log
    # errors /var/log/caddy/error.log
}

测试启动(Ctrl+c或者关闭终端会停止)

caddy -conf /etc/Caddyfile

注:
npm 编译可能有点慢 (确认自己服务器安装了nodejs)

使用服务方式使用 (restart、stop)

caddy -service start

欢迎支持我们的开源项目: https://github.com/notadd/notadd

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 1

内网的 git 仓库怎么进行发布

2年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!