我的git回购结构
app
- app.server
- server files
- app.client
- node_modules
- public
- src
- .dockerignore
- Dockerfile
- package.json
- package-log.json
我已经用GitHub操作设置了CI/CD,但我的客户端应用程序(React(的Dockerimage中出现了问题?
错误消息:COPY failed: file not found in build context or excluded by .dockerignore: stat package.json: file does not exist
我的.dockeringore文件:
node_modules
build
.dockerignore
Dockerfile
Dockerfile.prod
我的Dockerfile:
# pull official base image
FROM node:13.12.0-alpine
# set working directory
WORKDIR /app.client
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app.client/node_modules/.bin:$PATH
# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install --silent
RUN npm install react-scripts@3.4.1 -g --silent
# add app
COPY ./ ./
# start app
CMD ["npm", "start"]
我的GitHub操作命令调用Dockerfile:
docker build app.client/ -t mycontainerregistry.azurecr.io/appdb:${{ github.sha }}
这是我正在尝试学习的发布到Azure容器注册表的一部分。我想Dockerfile是有效的,因为在第4/9步失败之前,它会通过Dockerfile:
Step 1/9 : FROM node:13.12.0-alpine
13.12.0-alpine: Pulling from library/node
aad63a933944: Pulling fs layer
... (and so on)
Step 3/6 : COPY package.json ./
COPY failed: file not found in build context or excluded by .dockerignore: stat package.json: file does not exist
Error: Process completed with exit code 1.
WORKDIR
指容器中的工作目录。主机上的工作目录仍然是repo的根目录。