How to reduce image size for docker (app-router)
Unanswered
Turkish Van posted this in #help-forum
Turkish VanOP
my current Dockerfile:
My current docker-compose.yaml
the image size is aroud 500mb for me, I have looked into pages router docker image and it goes down to 150mb I didn't find a docker file for app router. How do I optimise my current image so it doesnt take up too much space?
# Stage 1: Install dependencies and build the app
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Stage 2: Run the app
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./
CMD ["npm", "run", "dev"]My current docker-compose.yaml
version: "3.5"
services:
app:
build:
context: .
dockerfile: Dockerfile
container_name: next-ui
ports:
- "3000:3000"
volumes:
- .:/app
env_file:
- .env.localthe image size is aroud 500mb for me, I have looked into pages router docker image and it goes down to 150mb I didn't find a docker file for app router. How do I optimise my current image so it doesnt take up too much space?