IndieCreator
V2EX  ›  Node.js

Node.js 请教一个动态更新的问题

  •  
  •   IndieCreator · Apr 4, 2023 · 2723 views
    This topic created in 1159 days ago, the information mentioned may be changed or developed.

    https://github.com/janishar/nodejs-backend-architecture-typescript 比如这个项目中, Install using Docker Compose [Recommended Method]

    Clone this repo. Make a copy of .env.example file to .env. Make a copy of keys/private.pem.example file to keys/private.pem. Make a copy of keys/public.pem.example file to keys/public.pem. Make a copy of tests/.env.test.example file to tests/.env.test. Install Docker and Docker Compose. Find Instructions Here. Execute docker-compose up -d in terminal from the repo directory. You will be able to access the api from http://localhost:3000 If having any issue then make sure 3000 port is not occupied else provide a different port in .env file. If having any issue then make sure 27017 port is not occupied else provide a different port in .env file.

    那我每次更新项目文件,我发现每次都得 docker rebuid 然后 restart 更新,有没有自动动态更新的方法

    8 replies    2023-04-11 11:50:01 +08:00
    gzlock
        1
    gzlock  
       Apr 4, 2023
    你这要求已经超出 docker 的使用规范了吧
    zbinlin
        2
    zbinlin  
       Apr 4, 2023
    你是用 docker 还是 docker compose ?如果是 docker compose 并且是 v2 版的,可以用 `docker compose alpha watch` 命令。
    如果是开发的话,或者不用 docker ,看它的 package.json 里有 watch 的 script ,可以直接用 `npm run watch`来开发。
    Trim21
        3
    Trim21  
       Apr 4, 2023
    本地开发直接用宿主机的 nodejs 跑 nodemon 就好了

    部属的时候才构建 docker 镜像然后推到服务器上。
    IndieCreator
        4
    IndieCreator  
    OP
       Apr 4, 2023
    @zbinlin 用的 docker compose ,谢谢我试试 docker compose alpha watch 命令
    IndieCreator
        5
    IndieCreator  
    OP
       Apr 4, 2023
    @Trim21 对 node 不是太熟,所以想怎么省事方便怎么来
    DICK23
        6
    DICK23  
       Apr 4, 2023
    你这已经是要求对文件监控了
    dendixx
        7
    dendixx  
       Apr 4, 2023
    @IndieCreator 方便就是 nodemon
    zy445566
        8
    zy445566  
       Apr 11, 2023
    https://github.com/virtual-less/vaas-framework
    我这个框架其实就实现了动态更新,有点类似 PHP
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2786 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 14:51 · PVG 22:51 · LAX 07:51 · JFK 10:51
    ♥ Do have faith in what you're doing.