From 5138f6aaa07a7fb9ae9456499e3d4e74ed2d0c59 Mon Sep 17 00:00:00 2001 From: Vishwas Naveen Date: Thu, 23 Jul 2026 12:08:01 +0530 Subject: [PATCH 1/2] feat(docker): add dockerfile and docker compose setup --- .dockerignore | 20 +++++++++++++++++++ Dockerfile | 33 ++++++++++++++++++++++++++++++ README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 27 +++++++++++++++++++++++++ next.config.ts | 1 + 5 files changed, 131 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..318bd7d39 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,20 @@ +node_modules +.next +.github +.git +.gitignore + +coverage +*.log +npm-debug.log* + +.env.local +.env + +Dockerfile +README.md + +.vscode +.idea + +!.env.local.example \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..379bb3082 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +#base image +FROM node:22-alpine AS base +WORKDIR /app + +FROM base AS deps +COPY package*.json ./ +RUN npm ci + +FROM base AS builder +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN npm run build + +#production image +FROM node:22-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=3000 +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +CMD [ "node", "server.js" ] \ No newline at end of file diff --git a/README.md b/README.md index 798eb2369..2dc804616 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,56 @@ npm run dev Then visit: `http://localhost:3000/api/streak?user=YOUR_USERNAME` +## 🐳 Docker + +CommitPulse includes Docker support for consistent local development and production deployments. + +### Prerequisites + +- Docker +- Docker Compose + +### Local Development + +1. Copy the example environment file: + +```bash +cp .env.local.example .env.local +``` + +2. Update the required environment variables in `.env.local` (such as `GITHUB_TOKEN`, `AUTH_SECRET`, and any optional integrations you plan to use). + +3. Start the application and MongoDB: + +```bash +docker compose up --build +``` + +The application will be available at: + +```text +http://localhost:3000 +``` + +MongoDB is automatically provisioned through Docker Compose. The `MONGODB_URI` is overridden to use the local MongoDB container, so no additional database configuration is required. + +### Production + +Build the production image: + +```bash +docker build -t commitpulse . +``` + +Run the container: + +```bash +docker run \ + --env-file .env.local \ + -p 3000:3000 \ + commitpulse +``` + ### 🌐 Deploy to Vercel [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/JhaSourav07/commitpulse&env=GITHUB_PAT&envDescription=GitHub%20Personal%20Access%20Token%20with%20read%3Auser%20scope) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..7f7ca8828 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + container_name: commitpulse-app + ports: + - '3000:3000' + env_file: + - .env.local + environment: + MONGODB_URI: mongodb://mongodb:27017/commitpulse + depends_on: + - mongodb + restart: unless-stopped + + mongodb: + image: mongo:8 + container_name: commitpulse-mongodb + ports: + - '27017:27017' + volumes: + - mongodb_data:/data/db + restart: unless-stopped + +volumes: + mongodb_data: diff --git a/next.config.ts b/next.config.ts index e2fa1cbaf..2b152882c 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import withSerwist from '@serwist/next'; import type { NextConfig } from 'next'; const nextConfig: NextConfig = { + output: 'standalone', serverExternalPackages: ['next/og', '@resvg/resvg-js'], allowedDevOrigins: process.env.NEXT_ALLOWED_DEV_ORIGINS ? process.env.NEXT_ALLOWED_DEV_ORIGINS.split(',') From 8f391c5873eb586571a79976e057859125a3fec4 Mon Sep 17 00:00:00 2001 From: Vishwas Naveen Date: Thu, 6 Aug 2026 13:15:00 +0530 Subject: [PATCH 2/2] feat(docker) : fixed docker image build issues --- docker-compose.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 7f7ca8828..60098dadb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,16 +11,23 @@ services: environment: MONGODB_URI: mongodb://mongodb:27017/commitpulse depends_on: - - mongodb + mongodb: + condition: service_healthy restart: unless-stopped mongodb: - image: mongo:8 + image: mongo:8.0 container_name: commitpulse-mongodb ports: - '27017:27017' volumes: - mongodb_data:/data/db + healthcheck: + test: ['CMD', 'mongosh', '--quiet', '--eval', "db.adminCommand('ping')"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 20s restart: unless-stopped volumes: