Skip to content

Commit cc32bb6

Browse files
Merge pull request #32 from yash-pouranik/feat/docker-setup
Feat/docker setup
2 parents 4f88fbb + b3e80bd commit cc32bb6

4 files changed

Lines changed: 104 additions & 0 deletions

File tree

.env.example

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ─────────────────────────────────────────────────────────────────────────────
2+
# urBackend — Environment Variables
3+
# Copy this file to .env and fill in your values before running docker-compose.
4+
# ─────────────────────────────────────────────────────────────────────────────
5+
6+
# Server
7+
PORT=1234
8+
NODE_ENV=production
9+
10+
# ── Database & Cache ──────────────────────────────────────────────────────────
11+
# When using docker-compose, these are automatically overridden to point to
12+
# internal service names (mongo, redis). You do NOT need to change these.
13+
MONGO_URL=mongodb://mongo:27017/urbackend
14+
REDIS_URL=redis://redis:6379
15+
16+
# ── Authentication ────────────────────────────────────────────────────────────
17+
JWT_SECRET=your_super_secret_jwt_key_min_32_chars
18+
ENCRYPTION_KEY=32_character_long_string_for_byod_creds
19+
API_KEY_SALT=your_random_api_key_salt
20+
21+
# ── External Storage (Supabase) ───────────────────────────────────────────────
22+
# Required for file upload/storage features.
23+
SUPABASE_URL=https://your-project.supabase.co
24+
SUPABASE_KEY=your-supabase-anon-key
25+
26+
# ── Email (Resend) ────────────────────────────────────────────────────────────
27+
# Required for OTP / email verification flow.
28+
RESEND_API_KEY=re_your_resend_api_key
29+
EMAIL_FROM=onboarding@resend.dev
30+
31+
# ── Frontend ──────────────────────────────────────────────────────────────────
32+
FRONTEND_URL=http://localhost:5173

backend/.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
.env
3+
*.log
4+
tests/
5+
.git
6+
.gitignore
7+
npm-debug.log*

backend/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ── Stage: Production ─────────────────────────────────────────────────────────
2+
FROM node:20-alpine
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Install dependencies first (layer caching)
8+
COPY package*.json ./
9+
RUN npm ci --omit=dev
10+
11+
# Copy source
12+
COPY . .
13+
14+
# Expose backend port
15+
EXPOSE 1234
16+
17+
# Start the server
18+
CMD ["node", "app.js"]

docker-compose.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
services:
3+
# ── MongoDB ───────────────────────────────────────────────────────────────────
4+
mongo:
5+
image: mongo:7
6+
container_name: urbackend_mongo
7+
restart: unless-stopped
8+
ports:
9+
- '27017:27017'
10+
volumes:
11+
- mongo_data:/data/db
12+
13+
# ── Redis ─────────────────────────────────────────────────────────────────────
14+
redis:
15+
image: redis:latest
16+
container_name: urbackend_redis
17+
restart: unless-stopped
18+
ports:
19+
- '6379:6379'
20+
volumes:
21+
- redis_data:/data
22+
23+
# ── Backend (Node.js) ─────────────────────────────────────────────────────────
24+
backend:
25+
build:
26+
context: ./backend
27+
dockerfile: Dockerfile
28+
container_name: urbackend_api
29+
restart: unless-stopped
30+
ports:
31+
- '1234:1234'
32+
depends_on:
33+
- mongo
34+
- redis
35+
env_file:
36+
- path: .env
37+
required: false
38+
environment:
39+
# Override DB URLs to use Docker service names
40+
MONGO_URL: mongodb://mongo:27017/urbackend
41+
REDIS_URL: redis://redis:6379
42+
NODE_ENV: production
43+
PORT: 1234
44+
45+
volumes:
46+
mongo_data:
47+
redis_data:

0 commit comments

Comments
 (0)