@@ -51,15 +51,40 @@ nano .env
5151
5252Update the following variables:
5353- ` DOMAIN ` : Your domain name (e.g., ` trakrlog.com ` or ` api.trakrlog.com ` )
54- - ` MONGODB_URL ` : MongoDB connection string (e.g., ` mongodb://admin:your_password@mongo:27017 ` )
54+ - ` MONGODB_URL ` : MongoDB connection string
55+ - For local container: ` mongodb://admin:your_password@mongo:27017 `
56+ - For MongoDB Atlas: ` mongodb+srv://user:pass@cluster.mongodb.net/ `
57+ - For other external MongoDB: Use your provider's connection string
5558- ` MONGODB_DATABASE ` : Database name (default: ` trakrlog ` )
56- - ` MONGODB_PASSWORD ` : MongoDB password (must match the password in MONGODB_URL )
59+ - ` MONGODB_PASSWORD ` : MongoDB root password (only needed for local container )
5760- ` SESSION_SECRET ` : Generate with ` openssl rand -hex 32 `
5861- ` GOOGLE_CLIENT_ID ` : Your Google OAuth client ID
5962- ` GOOGLE_CLIENT_SECRET ` : Your Google OAuth client secret
6063- ` GOOGLE_CALLBACK_URL ` : ` https://yourdomain.com/auth/google/callback `
6164
62- ### 4. Configure Google OAuth
65+ ### 4. Choose MongoDB Deployment Option
66+
67+ ** Option A: Use MongoDB Atlas (Recommended for Production)**
68+
69+ 1 . Create a free account at [ MongoDB Atlas] ( https://www.mongodb.com/cloud/atlas )
70+ 2 . Create a new cluster
71+ 3 . Get your connection string (looks like ` mongodb+srv://... ` )
72+ 4 . Set ` MONGODB_URL ` to your Atlas connection string in ` .env `
73+ 5 . Deploy without local MongoDB:
74+ ``` bash
75+ docker compose -f docker-compose.prod.yml up -d
76+ ```
77+
78+ ** Option B: Use Local MongoDB Container**
79+
80+ 1 . Set ` MONGODB_URL=mongodb://admin:yourpassword@mongo:27017 ` in ` .env `
81+ 2 . Set ` MONGODB_PASSWORD=yourpassword ` in ` .env `
82+ 3 . Deploy with local MongoDB:
83+ ``` bash
84+ docker compose -f docker-compose.prod.yml --profile local-db up -d
85+ ```
86+
87+ ### 5. Configure Google OAuth
6388
64891 . Go to [ Google Cloud Console] ( https://console.cloud.google.com/ )
65902 . Create a new project or select an existing one
@@ -69,27 +94,44 @@ Update the following variables:
6994 - ` https://yourdomain.com/auth/google/callback ` (production)
7095 - ` http://localhost:4000/auth/google/callback ` (local development)
7196
72- ### 5 . Build and deploy
97+ ### 6 . Build and deploy
7398
7499``` bash
75- # Build and start all services
100+ # Build and start all services (with external MongoDB like Atlas)
76101docker compose -f docker-compose.prod.yml up -d --build
77102
103+ # OR: Build and start with local MongoDB container
104+ docker compose -f docker-compose.prod.yml --profile local-db up -d --build
105+
78106# View logs
79107docker compose -f docker-compose.prod.yml logs -f
80108
81109# Check service status
82110docker compose -f docker-compose.prod.yml ps
83111```
84112
85- ### 6 . Verify deployment
113+ ### 7 . Verify deployment
86114
87115- Visit ` https://yourdomain.com ` - should show your frontend
88- - Visit ` https://yourdomain.com/api/health ` - should return health status
89- - Try logging in with Google OAuth
90-
91116## Architecture
92117
118+ ** With External MongoDB (e.g., Atlas):**
119+ ```
120+ ┌─────────────────┐
121+ │ Internet │
122+ └────────┬────────┘
123+ │
124+ ┌────▼────┐
125+ │ Caddy │ :80, :443 (Reverse Proxy + SSL)
126+ └────┬────┘
127+ │
128+ ┌────▼────┐ ┌──────────────┐
129+ │ App │ :4000 ────────────►│ MongoDB Atlas│
130+ └─────────┘ │ (External) │
131+ └──────────────┘
132+ ```
133+
134+ ** With Local MongoDB Container:**
93135```
94136┌─────────────────┐
95137│ Internet │
@@ -110,7 +152,11 @@ docker compose -f docker-compose.prod.yml ps
110152
111153## Services
112154
113- ### MongoDB
155+ ### MongoDB (Optional - use --profile local-db)
156+ - Internal port: 27017 (when using local container)
157+ - Data persisted in Docker volume: ` mongo_data `
158+ - Credentials configured via environment variables
159+ - ** Alternative** : Use MongoDB Atlas or any external MongoDB service
114160- Internal port: 27017
115161- Data persisted in Docker volume: ` mongo_data `
116162- Credentials configured via environment variables
0 commit comments