node.js - 使用 Bitbucket Pipelines NodeJS 应用程序部署到 VPS
问题描述
我对 Bitbucket Pipelines 有点陌生,我正在尝试设置一个 NodeJS api 来自动部署到数字海洋水滴,并且非常感谢一些建议,因为我已经尝试了两天!
我已经设法弄清楚如何 scp 部署npm run build
生成的 dist 目录,但我认为我需要的不仅仅是服务器上的目录,我是否正确?即 node_modules、package.json 等..?
这些是我尝试过的一些例子..
sftp
image: node:10.16.0
pipelines:
default:
- step:
name: Build API
caches:
- node
script:
- npm install
- npm run build
- step:
name: Deploy API PRODUCTION
deployment: production
script:
- pipe: atlassian/sftp-deploy:0.4.1
variables:
USER: $USER
SERVER: $PROD_SERVER
REMOTE_PATH: '/var/www/live'
拉上拉链
image: node:10.16.0
pipelines:
default:
- step:
name: Build API
caches:
- node
script:
- npm install
- npm run build
- tar czfv appname-api.tgz dist/ src/ node_modules/ package-lock.json package.json tsconfig.json tslint.json
artifacts:
- appname-api.tgz
- step:
name: Deploy API PRODUCTION
deployment: production
script:
- pipe: atlassian/scp-deploy:0.3.3
variables:
USER: $USER
SERVER: $PROD_SERVER
REMOTE_PATH: '/var/www/live'
LOCAL_PATH: 'appname-api.tgz'
以各种方式压缩它
tar --exclude='./git' -czfv appname-api.tgz ./
我想我可以做deploy.sh
一个 git pull,但我的 repos 是私有的,这意味着我必须为每台服务器添加 ssh 密钥等,所以这并不理想..
解决方案
推荐阅读
- vb.net - 更新不是 tableadapter 的成员
- java - 需要知道我是否可以使用 jmeter 对语音优先反应本机应用程序进行负载\性能测试
- javascript - vue拖放后拖动的项目消失
- jquery - 如何将偏移量应用于另一个页面上的#link
- xcode - 不能做 xcodebuild - 方案有一个空间
- orbeon - 使用自动完成的新组件
- scala - 如何让 Intellij 在 ammonite 脚本中解析私有 maven 存储库中的包?
- javascript - 两个按钮触发一个脚本
- laravel - 不同用户 Laravel 的身份验证(尝试获取非对象的属性)
- intellij-idea - 如何使用 IntelliJ 的结构替换“所有匹配项,除了...”?