Skip to content

Commit ca58180

Browse files
committed
feat: add Docker self-hosting support (Dockerfile, docker-compose, .env.example)
1 parent 5b4b1be commit ca58180

4 files changed

Lines changed: 103 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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: '3.9'
2+
3+
services:
4+
# ── MongoDB ───────────────────────────────────────────────────────────────────
5+
mongo:
6+
image: mongo:7
7+
container_name: urbackend_mongo
8+
restart: unless-stopped
9+
ports:
10+
- '27017:27017'
11+
volumes:
12+
- mongo_data:/data/db
13+
14+
# ── Redis ─────────────────────────────────────────────────────────────────────
15+
redis:
16+
image: redis:7-alpine
17+
container_name: urbackend_redis
18+
restart: unless-stopped
19+
ports:
20+
- '6379:6379'
21+
volumes:
22+
- redis_data:/data
23+
24+
# ── Backend (Node.js) ─────────────────────────────────────────────────────────
25+
backend:
26+
build:
27+
context: ./backend
28+
dockerfile: Dockerfile
29+
container_name: urbackend_api
30+
restart: unless-stopped
31+
ports:
32+
- '1234:1234'
33+
depends_on:
34+
- mongo
35+
- redis
36+
env_file:
37+
- .env
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+
44+
volumes:
45+
mongo_data:
46+
redis_data:

0 commit comments

Comments
 (0)