简体   繁体   English

构建 node-js docker 应用程序包括所有源文件

[英]Building a node-js docker app includes all sources files

I would like to run my node-js application in a docker instance, but at the same time, I would like to change some files (like.env or content-related files) without having to rebuild the docker-image.我想在 docker 实例中运行我的 node-js 应用程序,但与此同时,我想更改一些文件(如 .env 或与内容相关的文件)而不必重建 docker-image。 Currently, I build the image with this dockerfile:目前,我使用这个 dockerfile 构建图像:

FROM node:16
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm i --production
COPY . .
CMD ["node", "main.js"]

When I run the image on my Synology NAS I mounted a volume to the path /usr/scr/app`, but this does not change the behavior of the docker app.当我在我的 Synology NAS 上运行图像时,我将一个卷安装到路径 /usr/scr/app`,但这不会改变 docker 应用程序的行为。 It seems that all node sources are already in the image (or are ignored).似乎所有节点源都已在图像中(或被忽略)。

My goal would be that the image only contains node modules and the source files (.js) would be supplied via a mounted volume.我的目标是图像只包含节点模块,源文件 (.js) 将通过安装的卷提供。

How can I achieve this behavior?我怎样才能实现这种行为?

for env look at How do I pass environment variables to Docker containers?对于 env,请查看如何将环境变量传递给 Docker 容器?

for other not code => move it folder and mount this folder via volume对于其他非代码 => 将其移动到文件夹并通过卷挂载该文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM