这是我的dockerFile,位于 vDocker / Dockerfile
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
RUN apk add --no-cache bash
COPY ./vDocker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80 443
CMD ["nginx", "-g", "daemon off;"]
我在根目录下也有docker-compose。
version: '3'
services:
web_client:
build:
context: .
dockerfile: ./vDocker/Dockerfile
container_name: web_client
restart: unless-stopped
tty: true
volumes:
- /var/www/app/ssl/certbot/conf:/etc/letsencrypt
- /var/www/app/ssl/certbot/www:/var/www/certbot
ports:
- 80:80
- 443:443
运行docker-compose构建后,它给我以下错误:服务'web_client'构建失败:COPY失败:stat / var / lib / docker / overlay2 / 67b326c995a1ce52fb3ee2a792d84ffe9bc403aa5962755a2b89f1ab925a1242 / merged / app / dist:否此类文件或目录
知道为什么吗?
答案 0 :(得分:1)
您无需命名第二阶段。
您的构建外观如何取决于您的设置方式,我不知道。但是您可以做的是:
RUN ls -lart
->这将打印目录的内容,您可以检查/ app / dist是否确实存在其余的代码看起来不错。