V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
IndieCreator
V2EX  ›  Node.js

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

  •  
  •   IndieCreator · 2023-04-04 00:08:36 +08:00 · 1628 次点击
    这是一个创建于 382 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    部属的时候才构建 docker 镜像然后推到服务器上。
    IndieCreator
        4
    IndieCreator  
    OP
       2023-04-04 10:43:24 +08:00
    @zbinlin 用的 docker compose ,谢谢我试试 docker compose alpha watch 命令
    IndieCreator
        5
    IndieCreator  
    OP
       2023-04-04 10:44:06 +08:00
    @Trim21 对 node 不是太熟,所以想怎么省事方便怎么来
    DICK23
        6
    DICK23  
       2023-04-04 16:05:55 +08:00
    你这已经是要求对文件监控了
    dendixx
        7
    dendixx  
       2023-04-04 16:08:52 +08:00
    @IndieCreator 方便就是 nodemon
    zy445566
        8
    zy445566  
       2023-04-11 11:50:01 +08:00
    https://github.com/virtual-less/vaas-framework
    我这个框架其实就实现了动态更新,有点类似 PHP
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   899 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:21 · PVG 05:21 · LAX 14:21 · JFK 17:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.