Jac*_*ult 6 node.js npm docker aurelia windows-subsystem-for-linux
在我的 Windows 计算机上,我尝试使用以下 Dockerfile 构建容器化的 Node.js 应用程序:
# use latest version of nodejs
FROM node:lts-alpine
# install aurelia-cli to build the app & http-server to serve static contents
RUN npm i -g http-server
RUN npm i -g aurelia-cli
# set working directory to app
# henceforth all commands will run inside this folder
WORKDIR /app
# copy package.json related files first and install all required dependencies
COPY package*.json ./
RUN npm install
# copy the rest of the files and folders & install dependencies
COPY . ./
RUN npm run build
# by default http-server will serve contents on port 8080
# so we expose this port to host machine
EXPOSE 8080
CMD [ "http-server" , "dist" ]
Run Code Online (Sandbox Code Playgroud)
然而,docker build .
失败了Copy . ./
。与消息cannot replace to directory /var/lib/docker/overlay2/if2ip5okvavl8u6jpdtpczuog/merged/app/node_modules/@ampproject/remapping with file
。
我需要做什么才能构建容器映像?
Jac*_*ult 19
添加node_modules
到.dockerignore
与 Dockerfile 位于同一目录中的文件,如下所述: (h/t David Maze )。
不太优雅的是,只需删除项目的node_modules
目录然后重新运行即可docker build
。
归档时间: |
|
查看次数: |
7936 次 |
最近记录: |