So im building this Dockerfile to deploy my nextjs application. Now this dockerfile should build a production nextjs application. But my docker image is rather large 2.3gb. Here is my Dockerfile.
FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY public ./public
COPY app ./app
COPY components ./components
COPY ./lib /app/lib
COPY next.config.js ./
COPY pnpm-lock.yaml ./
COPY tailwind.config.ts ./
COPY tsconfig.json ./
COPY middleware.ts ./
COPY next-env.d.ts ./
COPY components.json ./
COPY auth.config.ts ./
COPY auth.ts ./
COPY postcss.config.js ./
RUN npm run build
RUN npm prune --production
EXPOSE 3000
CMD ["npx", "next", "start", "-H", "0.0.0.0", "-p", "3000"]
Also I know i can switch to an alpine image but I dont think this will decrease the image size much. Thanks in advance