Code Monkey home page Code Monkey logo

Comments (1)

surmon-china avatar surmon-china commented on May 21, 2024

@wojiaoerdandan 这个问题很有价值。

常规部署应用的做法:

  1. 生产机拉代码 git pull
  2. 安装依赖 yarn install
  3. 构建 yarn build
  4. 运行 yarn start

但由于我实际环境的生产机的性能不足以跑 “构建” 这一步(会死机),所以 “构建” 这一步被我转移到 GitHub Actions 进行:

GitHub Actions 在收到 push tags / release 事件后:

  1. 启动运行
  2. 安装依赖 yarn install
  3. 构建 yarn build
  4. 将构建后产物发布至 release 分支
  5. SSH 登录实际环境生产机,执行 deploy.sh 脚本

生产机 deploy.sh 脚本做的事情:

  1. 拉取最新代码 git pull
  2. 安装依赖 yarn install (这一部很重要,也就是你困惑的问题)
  3. release 分支的(构建后)代码拉取到本地的 dist 文件夹
  4. 运行程序 yarn start

可以看出:

  1. 我分解出的一个重要步骤是 yarn build 这一步,build 是对机器有性能要求的一步
  2. Node.js 应用在任何地方运行都需要保证 node_modules 是存在且有效的,所以我在生产机那里,只需要做 yarn install --frozen-lockfile --production 即可

from nodepress.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.