Node.js 请教一个动态更新的问题 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
IndieCreator
V2EX    Node.js

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

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

    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     Solana     5584 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 07:52 PVG 15:52 LAX 00:52 JFK 03:52
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86