diff --git a/.dockerignore b/.dockerignore index b512c09d476623ff4bf8d0d63c29b784925dbdf8..0334e68736f7cf6dce9fcb9f7645c9e34777ae3e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,25 @@ -node_modules \ No newline at end of file +# Node modules and build directories +node_modules +.next + +# IDE and editor settings +.vscode +.idea + +# System files +.DS_Store + +# Git repository files +.git +.gitignore + +# Logs and temporary files +*.log +*.tmp +*.swp + + +# Miscellaneous +npm-debug.log* +yarn-debug.log* +yarn-error.log* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 148e5b33435ed7c528b437db7692be412bd8a44f..b8f131a8257b7a6c77ff831a032f76c19d8f3494 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,38 @@ -ARG ARCH=linux/amd64 - -FROM --platform=$ARCH node:18 +# Stage 1: Install dependencies and build +FROM node:18-alpine AS builder +# Set the working directory WORKDIR /app +# Copy only the dependency files COPY package*.json ./ +# Install all dependencies RUN npm install +# Copy the rest of the application COPY . . -RUN npm run build +# Build the Next.js app +RUN npm run build + +# Stage 2: Runtime +FROM node:18-alpine AS runtime + +# Set the working directory +WORKDIR /app +# Copy only the production dependencies from the builder +COPY --from=builder /app/node_modules ./node_modules + +# Copy the build output and public assets +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public +COPY --from=builder /app/package*.json ./ + +# Expose the application port EXPOSE 3000 +# Start the Next.js application CMD ["npm", "start"] +