Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,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

Comment on lines +244 to +252
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)
Expand Down
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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:
condition: service_healthy
restart: unless-stopped

mongodb:
image: mongo:8.0
container_name: commitpulse-mongodb
ports:
- '27017:27017'
Comment on lines +21 to +22
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:
mongodb_data:
1 change: 1 addition & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { NextConfig } from 'next';
import withBundleAnalyzer from '@next/bundle-analyzer';

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(',')
Expand Down
Loading