This is my Dockerfile codes:
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"]
And I’ve .dockerignore file contains these :
.dockerignore
node_modules
npm-debug.*
Dockerfile
.git
.gitignore
I get this error in (step 8 copy . .)
Error processing tar file(duplicates of file paths not supported):
And one other problem is I must install git so there are two commands :
apk update && apk add git
because if I don’t in npm installation I get git error Idk why this happens if there is anyway that I be able to remove this command it would be better
2
Answers
I tried this Dockerfile on my side and it’s working correctly:
I see that you make unused steps like copy your code from base to builder after to prod , on this case you make a turn around without optimize your image layers .
You can Use the below Dockerfile to build you Nuxt image:
To build use this command:
This error can crop up if you have some docker internal files (namely
.wh..wh..opq
for my instance, there may be others in your instance) that are copied into your container. The solution here is to just delete them in your source as there’s no reason to keep them usually.