From 584b8728b5d3155fd9f4ef28ff0da7e621385f92 Mon Sep 17 00:00:00 2001 From: MayankSingh Date: Thu, 19 Feb 2026 09:56:41 +0530 Subject: [PATCH] feat: add production-ready Docker support using multi-stage build --- .dockerignore | 7 +++++++ Dockerfile | 32 ++++++++++++++++++++++++++++++++ README.md | 13 ++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..c9c5999e0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +.next +.git +.gitignore +Dockerfile +docker-compose.yml +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..856132aa1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# ---------- 1️⃣ Builder Stage ---------- +FROM node:18-alpine AS builder + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +RUN npm run build + + +# ---------- 2️⃣ Runner Stage ---------- +FROM node:18-alpine + +WORKDIR /app + +# Copy only package files +COPY package*.json ./ + +# Install ONLY production dependencies +RUN npm install --omit=dev + +# Copy built files from builder +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public + +EXPOSE 3000 + +CMD ["npm", "start"] diff --git a/README.md b/README.md index a01e2bd17..5eaa656e4 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,17 @@ This repo is **frontend only** – contributors can improve the design, add new ``` --- +## 🐳 Run with Docker (Production) + +Build the Docker image: + +```bash +docker build -t quickcart-prod . + +Run the container: +docker run -p 3000:3000 quickcart-prod +Then open: +http://localhost:3000 ## Contributing @@ -66,4 +77,4 @@ This project is licensed under the **MIT License**. ## 🌟 Contributors -Thanks to everyone who contributes to **QuickCart**! \ No newline at end of file +Thanks to everyone who contributes to **QuickCart**!