这是我的 Dockerfile 代码:
FROM node:16.10-alpine3.12 as base
RUN apk update
RUN apk add git
WORKDIR /app
COPY package.json .
FROM base as builder
RUN npm i
COPY . .
RUN npm run build
FROM base as prod
WORKDIR /exfront
COPY --from=builder /app/package.json .
RUN npm i
COPY --from=builder /app/.nuxt .nuxt
COPY --from=builder /app/static static
COPY --from=builder /app/nuxt.config.js .
EXPOSE 3500
ENV NUXT_HOST=0.0.0.0
ENV NUXT_PORT=3500
CMD ["npm","start"]
而且我的 .dockerignore 文件包含这些:
.dockerignore
node_modules
npm-debug.*
Dockerfile
.git
.gitignore
我在(第 8 步复制 ..)中收到此错误
Error processing tar file(duplicates of file paths not supported):
另一个问题是我必须安装 git,所以有两个命令:apk update && apk add git
因为如果我不在 npm 安装中,我会收到 git error Idk 为什么会发生这种情况,如果无论如何我可以删除这个命令,那就更好了
