From 68b6f4bcdac54ce800b4fd4ab9dbbf53c33bc499 Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 10:03:11 +0530 Subject: [PATCH 01/12] dockerize client standalone --- client/.dockerignore | 43 +++++++++++++++++++++++++++++++ client/Dockerfile | 53 ++++++++++++++++++++++++++++++++++++++ client/docker-compose.yaml | 22 ++++++++++++++++ client/nginx.conf | 39 ++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+) create mode 100644 client/.dockerignore create mode 100644 client/Dockerfile create mode 100644 client/docker-compose.yaml create mode 100644 client/nginx.conf diff --git a/client/.dockerignore b/client/.dockerignore new file mode 100644 index 00000000..0b0e02a6 --- /dev/null +++ b/client/.dockerignore @@ -0,0 +1,43 @@ +# Dependencies +node_modules +npm-debug.log +yarn-error.log +package-lock.json +yarn.lock + +# Build output +dist +build +.vercel + +# Environment variables +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# IDE +.vscode +.idea +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Git +.git +.gitignore +.gitattributes + +# Testing +coverage +.nyc_output + +# Misc +*.log +.vercelignore +README.md diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 00000000..afbbf07b --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,53 @@ +# Multi-stage Dockerfile for React + Vite Frontend + +# Development Stage +FROM node:20-alpine AS development + +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy source code +COPY . . + +# Expose Vite dev server port +EXPOSE 5173 + +# Start development server +CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"] + +# Build Stage +FROM node:20-alpine AS build + +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy source code +COPY . . + +# Build the application +RUN npm run build + +# Production Stage +FROM nginx:alpine AS production + +# Copy custom nginx configuration +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Copy built assets from build stage +COPY --from=build /app/dist /usr/share/nginx/html + +# Expose port 80 +EXPOSE 80 + +# Start nginx +CMD ["nginx", "-g", "daemon off;"] diff --git a/client/docker-compose.yaml b/client/docker-compose.yaml new file mode 100644 index 00000000..5ce48568 --- /dev/null +++ b/client/docker-compose.yaml @@ -0,0 +1,22 @@ +services: + client: + build: + context: . + dockerfile: Dockerfile + target: development + container_name: code-a2z-client + ports: + - '5173:5173' + env_file: + - .env + volumes: + - ./src:/app/src + - ./public:/app/public + - /app/node_modules + restart: unless-stopped + networks: + - code-a2z-network + +networks: + code-a2z-network: + driver: bridge diff --git a/client/nginx.conf b/client/nginx.conf new file mode 100644 index 00000000..4c1c2a06 --- /dev/null +++ b/client/nginx.conf @@ -0,0 +1,39 @@ +server { + listen 80; + server_name localhost; + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_vary on; + gzip_min_length 10240; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json; + gzip_disable "MSIE [1-6]\."; + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; + + # Handle React Router + location / { + try_files $uri $uri/ /index.html; + } + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Disable caching for index.html + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + expires 0; + } + + # Error pages + error_page 404 /index.html; +} From 8c84a53429822c967aa7a94bdc8d4bdb6ac2c9a7 Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 10:03:59 +0530 Subject: [PATCH 02/12] dockerize server standalone --- server/.dockerignore | 46 ++++++++++++++++++++++++++++- server/Dockerfile | 35 ++++++++++++++++++++-- server/docker-compose.yaml | 59 ++++++++++++++++++++++++++++---------- 3 files changed, 121 insertions(+), 19 deletions(-) diff --git a/server/.dockerignore b/server/.dockerignore index 7136e9e8..6ecd9b3b 100644 --- a/server/.dockerignore +++ b/server/.dockerignore @@ -1,4 +1,48 @@ +# Dependencies node_modules npm-debug.log +yarn-error.log +package-lock.json +yarn.lock + +# Environment variables +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# IDE +.vscode +.idea +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# Git .git -.gitignore \ No newline at end of file +.gitignore +.gitattributes + +# Docker +Dockerfile +docker-compose*.yaml +.dockerignore + +# Testing +coverage +.nyc_output + +# Misc +README.md diff --git a/server/Dockerfile b/server/Dockerfile index 0d47a0f5..bd7c685a 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,12 +1,41 @@ -FROM node:alpine +# Multi-stage Dockerfile for Node.js + Express Backend + +# Development Stage +FROM node:20-alpine AS development WORKDIR /app +# Copy package files COPY package*.json ./ -RUN npm install +# Install dependencies (including devDependencies for nodemon) +RUN npm install + +# Copy source code COPY . . +# Expose backend port +EXPOSE 8000 + +# Start development server with nodemon +CMD ["npm", "run", "dev"] + +# Production Stage +FROM node:20-alpine AS production + +WORKDIR /app +# Copy package files +COPY package*.json ./ + +# Install only production dependencies +RUN npm ci --only=production + +# Copy source code +COPY . . + +# Expose backend port EXPOSE 8000 -CMD [ "npm","start" ] \ No newline at end of file + +# Start production server +CMD ["npm", "start"] diff --git a/server/docker-compose.yaml b/server/docker-compose.yaml index 100e7a02..2b39dbb9 100644 --- a/server/docker-compose.yaml +++ b/server/docker-compose.yaml @@ -1,26 +1,55 @@ services: server: - image: server:latest + build: + context: . + dockerfile: Dockerfile + target: development + container_name: code-a2z-server ports: - '8000:8000' depends_on: - mongo + env_file: + - .env environment: - - PORT=${PORT} - - NODE_ENV=${NODE_ENV} # Change to 'development' for development environment - - VITE_SERVER_DOMAIN=${VITE_SERVER_DOMAIN} - - MONGODB_URL=mongodb://mongo:27017 - - JWT_ACCESS_EXPIRES_IN=${JWT_ACCESS_EXPIRES_IN} - - JWT_ACCESS_EXPIRES_IN_NUM=${JWT_ACCESS_EXPIRES_IN_NUM} - - JWT_REFRESH_EXPIRES_IN=${JWT_REFRESH_EXPIRES_IN} - - JWT_REFRESH_EXPIRES_IN_NUM=${JWT_REFRESH_EXPIRES_IN_NUM} - - CLOUDINARY_CLOUD_NAME=${CLOUDINARY_CLOUD_NAME} - - CLOUDINARY_API_KEY=${CLOUDINARY_API_KEY} - - CLOUDINARY_API_SECRET=${CLOUDINARY_API_SECRET} - - ADMIN_EMAIL=${ADMIN_EMAIL} - - RESEND_API_KEY=${RESEND_API_KEY} + - MONGODB_URL=mongodb://mongo:27017/code-a2z + volumes: + - ./src:/app/src + - ./logs:/app/logs + restart: unless-stopped + networks: + - code-a2z-network mongo: - image: mongo + image: mongo:8.2.2-noble + container_name: code-a2z-mongo ports: - '27017:27017' + volumes: + - mongo-data:/data/db + restart: unless-stopped + networks: + - code-a2z-network + + mongo-express: + image: mongo-express:latest + container_name: code-a2z-mongo-express + ports: + - '8081:8081' + environment: + - ME_CONFIG_MONGODB_URL=mongodb://mongo:27017 + - ME_CONFIG_BASICAUTH_USERNAME=admin + - ME_CONFIG_BASICAUTH_PASSWORD=admin123 + - ME_CONFIG_MONGODB_ENABLE_ADMIN=true + depends_on: + - mongo + restart: unless-stopped + networks: + - code-a2z-network + +volumes: + mongo-data: + +networks: + code-a2z-network: + driver: bridge From 17b8509eeec6fd14aff8036c00724ea839d8d7ab Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 10:05:24 +0530 Subject: [PATCH 03/12] dockerize full project --- docker-compose.yaml | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..48cc6532 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,78 @@ +services: + client: + build: + context: ./client + dockerfile: Dockerfile + target: development + container_name: code-a2z-client + ports: + - '5173:5173' + env_file: + - ./client/.env + environment: + - VITE_SERVER_DOMAIN=http://localhost:8000 + volumes: + - ./client/src:/app/src + - ./client/public:/app/public + - /app/node_modules + depends_on: + - server + restart: unless-stopped + networks: + - code-a2z-network + + server: + build: + context: ./server + dockerfile: Dockerfile + target: development + container_name: code-a2z-server + ports: + - '8000:8000' + depends_on: + - mongo + env_file: + - ./server/.env + environment: + - MONGODB_URL=mongodb://mongo:27017/code-a2z + - VITE_CLIENT_DOMAIN=http://localhost:5173 + volumes: + - ./server/src:/app/src + - ./server/logs:/app/logs + restart: unless-stopped + networks: + - code-a2z-network + + mongo: + image: mongo:8.2.2-noble + container_name: code-a2z-mongo + ports: + - '27017:27017' + volumes: + - mongo-data:/data/db + restart: unless-stopped + networks: + - code-a2z-network + + mongo-express: + image: mongo-express:latest + container_name: code-a2z-mongo-express + ports: + - '8081:8081' + environment: + - ME_CONFIG_MONGODB_URL=mongodb://mongo:27017 + - ME_CONFIG_BASICAUTH_USERNAME=admin + - ME_CONFIG_BASICAUTH_PASSWORD=admin123 + - ME_CONFIG_MONGODB_ENABLE_ADMIN=true + depends_on: + - mongo + restart: unless-stopped + networks: + - code-a2z-network + +volumes: + mongo-data: + +networks: + code-a2z-network: + driver: bridge From 8c8d0eed3d2262c2e2746f443e78a065cb01819f Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 10:05:54 +0530 Subject: [PATCH 04/12] add docker setup guide --- docs/DOCKER.md | 1094 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/SETUP.md | 2 +- 2 files changed, 1095 insertions(+), 1 deletion(-) create mode 100644 docs/DOCKER.md diff --git a/docs/DOCKER.md b/docs/DOCKER.md new file mode 100644 index 00000000..ed448e47 --- /dev/null +++ b/docs/DOCKER.md @@ -0,0 +1,1094 @@ +# Docker Setup Guide for Code A2Z + +This guide explains how to use Docker for development in the **Code A2Z** project. The Docker setup is organized by directory: + +- **`server/`** — Backend + MongoDB (server development) +- **`client/`** — Frontend only (UI development with deployed backend) +- **Root (`/`)** — Full Stack (complete development environment) + +--- + +## Prerequisites + +Before you begin, ensure you have the following installed: + +- **Docker Desktop** (version 20.10 or higher) + - [Download for macOS](https://docs.docker.com/desktop/install/mac-install/) + - [Download for Windows](https://docs.docker.com/desktop/install/windows-install/) + - [Download for Linux](https://docs.docker.com/desktop/install/linux-install/) +- **Docker Compose** (included with Docker Desktop) + +Verify installation: + +```bash +docker --version +docker-compose --version +``` + +--- + +## Project Structure + +``` +code-a2z/ +├── docker-compose.yaml # Full stack (client + server + mongo) +├── client/ +│ ├── Dockerfile # Frontend Docker image +│ ├── docker-compose.yaml # Frontend only +│ ├── nginx.conf # Production nginx config +│ └── .dockerignore +└── server/ + ├── Dockerfile # Backend Docker image + ├── docker-compose.yaml # Backend + MongoDB + └── .dockerignore +``` + +--- + +## Quick Start + +### Option 1: Backend-Only Development (Server + MongoDB) + +**Use when:** Working on backend features, APIs, or database logic. + +**From root directory:** + +```bash +npm run docker:server:up + +# View logs +npm run docker:server:logs + +# Stop when done +npm run docker:server:down +``` + +**Or from server directory:** + +```bash +cd server +npm run docker:up + +# View logs +npm run docker:logs +``` + +**Access:** + +- Backend API: `http://localhost:8000` +- MongoDB: `mongodb://localhost:27017/code-a2z` +- mongo-express: `http://localhost:8081` (admin/admin123) + +**Environment:** + +- Uses `server/.env` configuration +- MongoDB data persists in Docker volume +- Hot reload enabled with nodemon + +--- + +### Option 2: Frontend-Only Development (Client) + +**Use when:** Working on UI/UX, components, or client-side features without backend changes. + +**From root directory:** + +```bash +npm run docker:client:up + +# View logs +npm run docker:client:logs + +# Stop when done +npm run docker:client:down +``` + +**Or from client directory:** + +```bash +cd client +npm run docker:up + +# View logs +npm run docker:logs +``` + +**Access:** + +- Frontend: `http://localhost:5173` + +**Environment:** + +- Uses `client/.env` configuration +- Connects to deployed backend at `https://code-a2z-server.vercel.app` +- Hot reload enabled with Vite +- No backend or database required + +--- + +### Option 3: Full Stack Development (Client + Server + MongoDB) + +**Use when:** Working on features that require both frontend and backend changes. + +**From root directory:** + +```bash +npm run docker:up + +# View logs for all services +npm run docker:logs + +# View logs for specific service +docker-compose logs -f client +docker-compose logs -f server +docker-compose logs -f mongo + +# Stop when done +npm run docker:down +``` + +**Access:** + +- Frontend: `http://localhost:5173` +- Backend API: `http://localhost:8000` +- MongoDB: `mongodb://localhost:27017/code-a2z` +- mongo-express: `http://localhost:8081` (admin/admin123) + +**Environment:** + +- Uses both `client/.env` and `server/.env` +- All services communicate via Docker network +- Hot reload enabled for both client and server +- MongoDB data persists in Docker volume + +--- + +## NPM Scripts + +### Root Directory Commands + +You can run **all Docker commands from the root directory** for convenience: + +#### Full Stack (Client + Server + MongoDB) + +```bash +npm run docker:up # Start all services +npm run docker:down # Stop all services +npm run docker:logs # View all logs (real-time) +npm run docker:build # Build all images +npm run docker:restart # Restart all services +npm run docker:clean # Remove containers, volumes, and prune system +``` + +#### Frontend Only + +```bash +npm run docker:client:up # Start frontend only +npm run docker:client:down # Stop frontend only +npm run docker:client:logs # View frontend logs (real-time) +npm run docker:client:build # Build frontend image +npm run docker:client:restart # Restart frontend +``` + +#### Backend Only (Server + MongoDB) + +```bash +npm run docker:server:up # Start backend + MongoDB +npm run docker:server:down # Stop backend + MongoDB +npm run docker:server:logs # View backend logs (real-time) +npm run docker:server:build # Build backend image +npm run docker:server:restart # Restart backend +``` + +--- + +### Client Directory Commands + +If you're working exclusively in the `client/` directory: + +```bash +cd client +npm run docker:up # Start frontend +npm run docker:down # Stop frontend +npm run docker:logs # View frontend logs +npm run docker:build # Build frontend image +npm run docker:restart # Restart frontend +``` + +--- + +### Server Directory Commands + +If you're working exclusively in the `server/` directory: + +```bash +cd server +npm run docker:up # Start backend + MongoDB +npm run docker:down # Stop backend + MongoDB +npm run docker:logs # View backend logs +npm run docker:build # Build backend image +npm run docker:restart # Restart backend +``` + +--- + +## Detailed Commands + +### Building Images + +```bash +# Backend only +cd server +docker-compose build +# or +npm run docker:build + +# Frontend only +cd client +docker-compose build +# or +npm run docker:build + +# Full stack (from root) +docker-compose build +# or +npm run docker:build + +# Force rebuild without cache +docker-compose build --no-cache +``` + +### Starting Services + +```bash +# Start in foreground (see logs) +docker-compose up + +# Start in background (detached) +docker-compose up -d +# or +npm run docker:up + +# Start specific service (full stack only) +docker-compose up client +docker-compose up server +``` + +### Stopping Services + +```bash +# Stop all services +docker-compose down +# or +npm run docker:down + +# Stop and remove volumes (deletes MongoDB data) +docker-compose down -v + +# Stop specific service +docker-compose stop client +``` + +### Viewing Logs + +```bash +# All services +docker-compose logs +# or +npm run docker:logs + +# Follow logs (real-time) +docker-compose logs -f + +# Specific service +docker-compose logs -f server +docker-compose logs -f client + +# Last 100 lines +docker-compose logs --tail=100 +``` + +### Executing Commands in Containers + +```bash +# Open shell in backend container +docker exec -it code-a2z-server sh + +# Open shell in frontend container +docker exec -it code-a2z-client sh + +# Run npm command in container +docker exec -it code-a2z-server npm install +docker exec -it code-a2z-client npm install + +# Access MongoDB shell +docker exec -it code-a2z-mongo mongosh +``` + +--- + +## MongoDB Interaction & Data Inspection + +When your API isn't working properly or you want to verify data storage, you have several options to interact with MongoDB. + +### Option 1: mongo-express - Web-based GUI (Recommended for Docker) + +**mongo-express** is a web-based MongoDB admin interface that runs as a Docker container alongside your database. + +**Access:** + +- URL: `http://localhost:8081` +- Username: `admin` +- Password: `admin123` + +**Features:** + +- ✅ Browser-based interface - No installation required +- ✅ Visual database browser with collections +- ✅ CRUD operations (Create, Read, Update, Delete) +- ✅ Document viewer and editor +- ✅ Query builder +- ✅ Import/Export data +- ✅ Automatic updates when data changes +- ✅ Runs automatically with your Docker setup + +**Usage:** + +1. Start your Docker environment: + +```bash +# Full stack +npm run docker:up + +# Or backend only +npm run docker:server:up +``` + +2. Open browser and navigate to `http://localhost:8081` + +3. Login with credentials: + - Username: `admin` + - Password: `admin123` + +4. Select `code-a2z` database + +5. Browse collections (users, projects, comments, etc.) + +6. View, edit, or delete documents directly + +**Common Tasks:** + +- **View all users**: Click on `users` collection → View Documents +- **Search documents**: Use the search bar at the top +- **Edit document**: Click on document → Click Edit → Modify → Save +- **Delete document**: Click on document → Delete button +- **Add new document**: Click "New Document" → Enter JSON → Save +- **Export collection**: Click on collection → Export + +> [!TIP] +> mongo-express is automatically started when you run `npm run docker:up` or `npm run docker:server:up`. No extra setup needed! + +> [!WARNING] +> The default credentials (`admin`/`admin123`) are for development only. Change them in production by modifying the `ME_CONFIG_BASICAUTH_USERNAME` and `ME_CONFIG_BASICAUTH_PASSWORD` environment variables in `docker-compose.yaml`. + +--- + +### Option 2: MongoDB Shell (mongosh) - Command Line + +Access the MongoDB shell directly from your terminal: + +```bash +# Access MongoDB shell +docker exec -it code-a2z-mongo mongosh + +# Once inside mongosh, use these commands: +show dbs # List all databases +use code-a2z # Switch to code-a2z database +show collections # List all collections + +# View documents +db.users.find() # Get all users +db.users.find().pretty() # Get all users (formatted) +db.users.findOne() # Get one user +db.users.find({ email: "test@example.com" }) # Find by field + +db.projects.find() # Get all projects +db.projects.countDocuments() # Count projects + +# Find with specific fields +db.users.find({}, { fullname: 1, email: 1, _id: 0 }) + +# Sort and limit +db.projects.find().sort({ createdAt: -1 }).limit(10) + +# Exit mongosh +exit +``` + +### Option 3: MongoDB Compass - GUI Tool + +**MongoDB Compass** is the official GUI tool for MongoDB. It's the easiest way to visualize and interact with your data. + +**Installation:** + +1. Download from [MongoDB Compass](https://www.mongodb.com/products/tools/compass) +2. Install and open MongoDB Compass + +**Connection:** + +``` +Connection String: mongodb://localhost:27017 +``` + +**Features:** + +- ✅ Visual database browser +- ✅ Query builder with autocomplete +- ✅ Document editor +- ✅ Performance monitoring +- ✅ Index management +- ✅ Schema analysis + +**Steps:** + +1. Open MongoDB Compass +2. Enter connection string: `mongodb://localhost:27017` +3. Click "Connect" +4. Navigate to `code-a2z` database +5. Explore collections: `users`, `projects`, `comments`, etc. + +### Option 4: VS Code Extensions + +Install MongoDB extensions in VS Code: + +**Recommended Extension:** + +- **MongoDB for VS Code** (by MongoDB) + - Extension ID: `mongodb.mongodb-vscode` + +**Setup:** + +1. Install the extension +2. Click MongoDB icon in sidebar +3. Add connection: `mongodb://localhost:27017` +4. Browse databases and collections +5. Run queries directly in VS Code + +### Option 5: mongosh One-Liners + +Execute queries directly from your terminal without entering the shell: + +```bash +# List all databases +docker exec -it code-a2z-mongo mongosh --eval "show dbs" + +# Count users +docker exec -it code-a2z-mongo mongosh code-a2z --eval "db.users.countDocuments()" + +# Find specific user +docker exec -it code-a2z-mongo mongosh code-a2z --eval 'db.users.findOne({ email: "test@example.com" })' + +# Get all project titles +docker exec -it code-a2z-mongo mongosh code-a2z --eval 'db.projects.find({}, { title: 1, _id: 0 })' +``` + +### Common MongoDB Queries for Debugging + +```javascript +// Inside mongosh (docker exec -it code-a2z-mongo mongosh) + +use code-a2z + +// Check if user exists +db.users.findOne({ email: "user@example.com" }) + +// Check recent projects +db.projects.find().sort({ createdAt: -1 }).limit(5).pretty() + +// Count documents in each collection +db.users.countDocuments() +db.projects.countDocuments() +db.comments.countDocuments() + +// Find projects by author +db.projects.find({ "author.email": "user@example.com" }).pretty() + +// Check for draft vs published projects +db.projects.countDocuments({ draft: true }) +db.projects.countDocuments({ draft: false }) + +// Find recent notifications +db.notifications.find().sort({ createdAt: -1 }).limit(10).pretty() + +// Check indexes +db.users.getIndexes() +db.projects.getIndexes() + +// Database stats +db.stats() +``` + +### Backup and Restore MongoDB Data + +**Backup:** + +```bash +# Create backup directory +mkdir -p ./backups + +# Backup all databases +docker exec code-a2z-mongo mongodump --out /data/backup + +# Copy backup to host +docker cp code-a2z-mongo:/data/backup ./backups/ + +# Or backup directly to host +docker exec code-a2z-mongo mongodump --out /data/backup && \ +docker cp code-a2z-mongo:/data/backup ./backups/mongodb-backup-$(date +%Y%m%d) +``` + +**Restore:** + +```bash +# Copy backup to container +docker cp ./backups/mongodb-backup-20250120 code-a2z-mongo:/data/restore + +# Restore database +docker exec code-a2z-mongo mongorestore /data/restore +``` + +### Export/Import Specific Collections + +**Export to JSON:** + +```bash +# Export users collection +docker exec code-a2z-mongo mongoexport --db=code-a2z --collection=users --out=/data/users.json + +# Copy to host +docker cp code-a2z-mongo:/data/users.json ./users.json +``` + +**Import from JSON:** + +```bash +# Copy to container +docker cp ./users.json code-a2z-mongo:/data/users.json + +# Import +docker exec code-a2z-mongo mongoimport --db=code-a2z --collection=users --file=/data/users.json +``` + +### MongoDB Container Logs + +View MongoDB logs to debug connection issues: + +```bash +# View MongoDB logs +docker logs code-a2z-mongo + +# Follow logs in real-time +docker logs -f code-a2z-mongo + +# Last 100 lines +docker logs --tail=100 code-a2z-mongo +``` + +### Quick MongoDB Health Check + +```bash +# Check if MongoDB is running +docker ps | grep mongo + +# Check MongoDB status +docker exec -it code-a2z-mongo mongosh --eval "db.adminCommand('ping')" + +# Check database size +docker exec -it code-a2z-mongo mongosh code-a2z --eval "db.stats()" +``` + +--- + +## Environment Configuration + +### Backend Environment Variables + +Create `server/.env` from `server/.env.example`: + +```bash +cd server +cp .env.example .env +``` + +**Important variables for Docker:** + +```env +# For backend-only or fullstack mode +MONGODB_URL=mongodb://mongo:27017/code-a2z + +# Other required variables +JWT_SECRET_ACCESS_KEY=your_secret_key +JWT_SECRET_REFRESH_KEY=your_refresh_key +CLOUDINARY_CLOUD_NAME=your_cloudinary_name +CLOUDINARY_API_KEY=your_api_key +CLOUDINARY_API_SECRET=your_api_secret +ADMIN_EMAIL=your_email +RESEND_API_KEY=your_resend_key +``` + +### Frontend Environment Variables + +Create `client/.env` from `client/.env.example`: + +```bash +cd client +cp .env.example .env +``` + +**For frontend-only mode (deployed backend):** + +```env +VITE_SERVER_DOMAIN=https://code-a2z-server.vercel.app +``` + +**For fullstack mode (local backend):** + +```env +VITE_SERVER_DOMAIN=http://localhost:8000 +``` + +> [!NOTE] +> When using fullstack Docker, the frontend can also access the backend via the Docker network using `http://server:8000`, but `http://localhost:8000` works fine since ports are exposed. + +--- + +## Volume Management + +### Persistent Data + +MongoDB data is stored in a Docker volume to persist across container restarts. + +```bash +# List volumes +docker volume ls + +# Inspect volume +docker volume inspect code-a2z_mongo-data + +# Remove volume (deletes all database data) +docker volume rm code-a2z_mongo-data +``` + +### Node Modules + +Node modules are stored in anonymous volumes to improve performance: + +```bash +# Client container has: /app/node_modules +# Server container has: /app/node_modules +``` + +This prevents conflicts between host and container dependencies. + +--- + +## Troubleshooting + +### Port Already in Use + +**Error:** `Bind for 0.0.0.0:8000 failed: port is already allocated` + +**Solution:** + +```bash +# Find and kill the process using the port +lsof -ti:8000 | xargs kill -9 +lsof -ti:5173 | xargs kill -9 +lsof -ti:27017 | xargs kill -9 + +# Or change port in docker-compose file +``` + +### MongoDB Connection Failed + +**Error:** `MongoServerError: Authentication failed` + +**Solution:** + +- Ensure `MONGODB_URL` in `server/.env` is set to `mongodb://mongo:27017/code-a2z` +- Remove volumes and restart: `docker-compose down -v && docker-compose up` + +### Hot Reload Not Working + +**Frontend:** + +- Ensure Vite is started with `--host 0.0.0.0` flag (already configured) +- Check that `src` directory is mounted as volume + +**Backend:** + +- Ensure nodemon is watching the correct directories +- Check that `src` directory is mounted as volume + +### Permission Denied Errors + +**macOS/Linux:** + +```bash +# Fix permissions +sudo chown -R $USER:$USER . +``` + +**Windows:** + +- Run Docker Desktop as Administrator +- Enable WSL 2 backend + +### Build Failures + +```bash +# Clear Docker cache and rebuild +docker-compose -f docker-compose.fullstack.yaml build --no-cache + +# Remove all containers and images +docker-compose -f docker-compose.fullstack.yaml down +docker system prune -a +``` + +### Cannot Connect to Backend from Frontend + +**Solution:** + +- Ensure both services are on the same Docker network +- Check `VITE_SERVER_DOMAIN` environment variable +- For fullstack mode, use `http://localhost:8000` (not `http://server:8000` from browser) + +--- + +## Production Build + +### Frontend Production Build + +```bash +# Build production image +cd client +docker build --target production -t code-a2z-client:prod . + +# Run production container +docker run -p 80:80 code-a2z-client:prod +``` + +**Access:** `http://localhost` + +### Backend Production Build + +```bash +# Build production image +cd server +docker build --target production -t code-a2z-server:prod . + +# Run production container +docker run -p 8000:8000 --env-file .env code-a2z-server:prod +``` + +--- + +## Docker Compose File Reference + +### Backend Only: `server/docker-compose.yaml` + +- **Location:** `server/docker-compose.yaml` +- **Services:** `server`, `mongo` +- **Networks:** `code-a2z-network` +- **Volumes:** `mongo-data` (persistent) +- **Ports:** 8000 (server), 27017 (mongo) +- **Usage:** `cd server && npm run docker:up` + +### Frontend Only: `client/docker-compose.yaml` + +- **Location:** `client/docker-compose.yaml` +- **Services:** `client` +- **Networks:** `code-a2z-network` +- **Ports:** 5173 (client) +- **External API:** Uses deployed backend +- **Usage:** `cd client && npm run docker:up` + +### Full Stack: `docker-compose.yaml` + +- **Location:** Root directory (`docker-compose.yaml`) +- **Services:** `client`, `server`, `mongo` +- **Networks:** `code-a2z-network` +- **Volumes:** `mongo-data` (persistent) +- **Ports:** 5173 (client), 8000 (server), 27017 (mongo) +- **Usage:** `npm run docker:up` (from root) + +--- + +## Best Practices + +### Development + +1. **Use volume mounts** for hot reload during development +2. **Keep `.env` files up to date** with required variables +3. **Run `docker-compose logs -f`** to monitor issues in real-time +4. **Use named volumes** for databases to prevent data loss + +### Cleanup + +```bash +# Stop all containers +docker stop $(docker ps -aq) + +# Remove all containers +docker rm $(docker ps -aq) + +# Remove all images +docker rmi $(docker images -q) + +# Remove all volumes (WARNING: deletes database data) +docker volume prune + +# Complete cleanup +docker system prune -a --volumes +``` + +### Optimization + +1. **Use multi-stage builds** for smaller production images +2. **Leverage `.dockerignore`** to exclude unnecessary files +3. **Cache dependencies** by copying `package.json` before source code +4. **Use Alpine images** for smaller footprint + +--- + +## Switching Between Modes + +### From Frontend-Only to Full Stack + +```bash +# Stop frontend-only (from root) +npm run docker:client:down + +# Update client/.env +echo "VITE_SERVER_DOMAIN=http://localhost:8000" > client/.env + +# Start full stack +npm run docker:up +``` + +### From Full Stack to Backend-Only + +```bash +# Stop full stack (from root) +npm run docker:down + +# Start backend only +npm run docker:server:up +``` + +### From Backend-Only to Frontend-Only + +```bash +# Stop backend (from root) +npm run docker:server:down + +# Start frontend +npm run docker:client:up +``` + +### Quick Switch Examples + +```bash +# Switch from client to server +npm run docker:client:down && npm run docker:server:up + +# Switch from server to full stack +npm run docker:server:down && npm run docker:up + +# Restart everything +npm run docker:down && npm run docker:up +``` + +--- + +## Common Use Cases + +### 1. Working on Backend APIs + +**From root directory:** + +```bash +npm run docker:server:up +# Make changes to server/src files +# Changes auto-reload with nodemon + +# View logs +npm run docker:server:logs + +# Stop when done +npm run docker:server:down +``` + +**Or from server directory:** + +```bash +cd server +npm run docker:up +# Make changes to server/src files +# Changes auto-reload with nodemon +``` + +### 2. Working on UI Components + +**From root directory:** + +```bash +npm run docker:client:up +# Make changes to client/src files +# Changes auto-reload with Vite + +# View logs +npm run docker:client:logs + +# Stop when done +npm run docker:client:down +``` + +**Or from client directory:** + +```bash +cd client +npm run docker:up +# Make changes to client/src files +# Changes auto-reload with Vite +``` + +### 3. Full Feature Development + +**From root directory:** + +```bash +npm run docker:up +# Work on both frontend and backend +# Both auto-reload on changes + +# View all logs +npm run docker:logs + +# Stop when done +npm run docker:down +``` + +### 4. Database Operations + +```bash +# Access MongoDB shell +docker exec -it code-a2z-mongo mongosh + +# Backup database +docker exec code-a2z-mongo mongodump --out /backup + +# Restore database +docker exec code-a2z-mongo mongorestore /backup +``` + +### 5. Rebuilding Images After Dependency Changes + +**From root directory:** + +```bash +# Rebuild specific service +npm run docker:client:build +npm run docker:server:build + +# Or rebuild all services +npm run docker:build +``` + +### 6. Cleaning Up Docker Resources + +**From root directory:** + +```bash +# Stop and remove all containers, volumes, and prune system +npm run docker:clean + +# Or just stop services +npm run docker:down +``` + +--- + +## Additional Resources + +- [Docker Documentation](https://docs.docker.com/) +- [Docker Compose Documentation](https://docs.docker.com/compose/) +- [MongoDB Docker Hub](https://hub.docker.com/_/mongo) +- [Node.js Docker Hub](https://hub.docker.com/_/node) +- [Nginx Docker Hub](https://hub.docker.com/_/nginx) + +--- + +## Getting Help + +If you encounter issues: + +1. Check the **Troubleshooting** section above +2. Review Docker logs: `docker-compose logs -f` +3. Verify environment variables in `.env` files +4. Ensure Docker Desktop is running +5. Try rebuilding: `docker-compose build --no-cache` +6. Ask in the project's Discord community + +--- + +## Summary + +| Mode | Root Command | Directory Command | Use Case | +| ----------------- | -------------------------- | -------------------------------- | --------------------------------------- | +| **Full Stack** | `npm run docker:up` | N/A | Features requiring both FE & BE changes | +| **Frontend Only** | `npm run docker:client:up` | `cd client && npm run docker:up` | UI/UX, components, client-side logic | +| **Backend Only** | `npm run docker:server:up` | `cd server && npm run docker:up` | API development, database work | + +**Directory Structure:** + +- **Root**: Full stack development (`docker-compose.yaml`) +- **`client/`**: Frontend-only development (`docker-compose.yaml`) +- **`server/`**: Backend-only development (`docker-compose.yaml`) + +**Access URLs:** + +- **Frontend**: `http://localhost:5173` +- **Backend API**: `http://localhost:8000` +- **MongoDB**: `mongodb://localhost:27017/code-a2z` +- **mongo-express**: `http://localhost:8081` (admin/admin123) + +**Pro Tip:** All commands can be run from the root directory for maximum convenience! 🚀 + +### Complete Command Reference + +```bash +# Full Stack (from root) +npm run docker:up # Start all services +npm run docker:down # Stop all services +npm run docker:logs # View logs +npm run docker:build # Build images +npm run docker:restart # Restart services +npm run docker:clean # Clean up everything + +# Frontend Only (from root) +npm run docker:client:up # Start frontend +npm run docker:client:down # Stop frontend +npm run docker:client:logs # View logs +npm run docker:client:build # Build image +npm run docker:client:restart # Restart + +# Backend Only (from root) +npm run docker:server:up # Start backend + MongoDB +npm run docker:server:down # Stop backend + MongoDB +npm run docker:server:logs # View logs +npm run docker:server:build # Build image +npm run docker:server:restart # Restart +``` + +Choose the mode that fits your development needs and start coding! 🚀 diff --git a/docs/SETUP.md b/docs/SETUP.md index 5e295e81..b8e2ce0e 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -170,7 +170,7 @@ npm run client **Reason:** Wrong `VITE_SERVER_DOMAIN` **Fix:** -- Local mode → set to `http://localhost:8000/api` +- Local mode → set to `http://localhost:8000` - Frontend mode → set to deployed backend ### File uploads not working From 51ac2323ac8f0c1f40b369e4da33abb6f32f2620 Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 10:06:30 +0530 Subject: [PATCH 05/12] add docker npm scripts --- client/package.json | 7 ++++++- package.json | 20 ++++++++++++++++++-- server/package.json | 7 ++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/client/package.json b/client/package.json index 4a5e9518..50995590 100644 --- a/client/package.json +++ b/client/package.json @@ -18,7 +18,12 @@ "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", - "preview": "vite preview" + "preview": "vite preview", + "docker:up": "docker-compose up -d", + "docker:down": "docker-compose down", + "docker:logs": "docker-compose logs -f", + "docker:build": "docker-compose build", + "docker:restart": "docker-compose restart" }, "dependencies": { "@editorjs/attaches": "^1.3.2", diff --git a/package.json b/package.json index b04731fc..7135ebfb 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "test": "echo \"Error: no test specified\" && exit 1", "install:client": "cd client && npm install", "install:server": "cd server && npm install", - "install:all": "npm install && cd client && npm install && cd ../server && npm install", + "install": "npm install && cd client && npm install && cd ../server && npm install", "client": "cd client && npm run dev", "server": "cd server && npm run dev", "dev": "concurrently -n \"CLIENT,SERVER\" -c \"bgBlue.bold,bgMagenta.bold\" \"npm run client\" \"npm run server\"", @@ -39,7 +39,23 @@ "format:client": "prettier --write \"client/src/**/*.{ts,tsx,js,jsx,css,html}\"", "format:server": "prettier --write \"server/**/*.js\"", "format:docs": "prettier --write \"*.{json,md,yml,yaml}\"", - "precommit-check": "npm run lint && npm run format:check" + "precommit-check": "npm run lint && npm run format:check", + "docker:up": "docker-compose up -d", + "docker:down": "docker-compose down", + "docker:logs": "docker-compose logs -f", + "docker:build": "docker-compose build", + "docker:restart": "docker-compose restart", + "docker:clean": "docker-compose down -v && docker system prune -f", + "docker:client:up": "cd client && docker-compose up -d", + "docker:client:down": "cd client && docker-compose down", + "docker:client:logs": "cd client && docker-compose logs -f", + "docker:client:build": "cd client && docker-compose build", + "docker:client:restart": "cd client && docker-compose restart", + "docker:server:up": "cd server && docker-compose up -d", + "docker:server:down": "cd server && docker-compose down", + "docker:server:logs": "cd server && docker-compose logs -f", + "docker:server:build": "cd server && docker-compose build", + "docker:server:restart": "cd server && docker-compose restart" }, "devDependencies": { "@eslint/css": "^0.10.0", diff --git a/server/package.json b/server/package.json index b5e43771..b1d4f016 100644 --- a/server/package.json +++ b/server/package.json @@ -23,7 +23,12 @@ "test": "echo \"Error: no test specified\" && exit 1", "start": "node index.js", "dev": "nodemon index.js", - "build": "echo 'No build process required'" + "build": "echo 'No build process required'", + "docker:up": "docker-compose up -d", + "docker:down": "docker-compose down", + "docker:logs": "docker-compose logs -f", + "docker:build": "docker-compose build", + "docker:restart": "docker-compose restart" }, "dependencies": { "bcrypt": "^5.1.1", From 00087579435d5fecf94fdff470d8d59d4b9ad969 Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 10:06:53 +0530 Subject: [PATCH 06/12] fixed CORS error --- server/src/server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/server.js b/server/src/server.js index 31650e16..2d9ce00d 100644 --- a/server/src/server.js +++ b/server/src/server.js @@ -24,10 +24,10 @@ server.use(express.json()); server.use(cookieParser()); server.use( cors({ - origin: '*', + origin: true, credentials: true, - methods: 'GET,POST,PUT,DELETE', - allowedHeaders: 'Content-Type,Authorization', + methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], + allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'], }) ); From 79a330298ab154be076d91000c4cc4f5d00240a4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:13:57 +0000 Subject: [PATCH 07/12] Initial plan From 62296c4d84efa72f4b76990bc1f5c2fb8d77f0fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:19:07 +0000 Subject: [PATCH 08/12] Address PR review comments: security, Docker best practices, and documentation fixes Co-authored-by: Avdhesh-Varshney <114330097+Avdhesh-Varshney@users.noreply.github.com> --- client/.dockerignore | 1 - client/nginx.conf | 1 + docker-compose.yaml | 26 +++++++++++++++++++------- docs/DOCKER.md | 4 ++-- server/.dockerignore | 2 +- server/Dockerfile | 2 +- server/docker-compose.yaml | 6 +++--- 7 files changed, 27 insertions(+), 15 deletions(-) diff --git a/client/.dockerignore b/client/.dockerignore index 0b0e02a6..a3d834c9 100644 --- a/client/.dockerignore +++ b/client/.dockerignore @@ -2,7 +2,6 @@ node_modules npm-debug.log yarn-error.log -package-lock.json yarn.lock # Build output diff --git a/client/nginx.conf b/client/nginx.conf index 4c1c2a06..32dcd5be 100644 --- a/client/nginx.conf +++ b/client/nginx.conf @@ -16,6 +16,7 @@ server { add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; # Handle React Router location / { diff --git a/docker-compose.yaml b/docker-compose.yaml index 48cc6532..01a494a7 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,12 +9,10 @@ services: - '5173:5173' env_file: - ./client/.env - environment: - - VITE_SERVER_DOMAIN=http://localhost:8000 volumes: - ./client/src:/app/src - ./client/public:/app/public - - /app/node_modules + - client_node_modules:/app/node_modules depends_on: - server restart: unless-stopped @@ -30,7 +28,8 @@ services: ports: - '8000:8000' depends_on: - - mongo + mongo: + condition: service_healthy env_file: - ./server/.env environment: @@ -40,17 +39,29 @@ services: - ./server/src:/app/src - ./server/logs:/app/logs restart: unless-stopped + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/monitor/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s networks: - code-a2z-network mongo: - image: mongo:8.2.2-noble + image: mongo:7-noble container_name: code-a2z-mongo ports: - '27017:27017' volumes: - mongo-data:/data/db restart: unless-stopped + healthcheck: + test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 10s networks: - code-a2z-network @@ -61,8 +72,8 @@ services: - '8081:8081' environment: - ME_CONFIG_MONGODB_URL=mongodb://mongo:27017 - - ME_CONFIG_BASICAUTH_USERNAME=admin - - ME_CONFIG_BASICAUTH_PASSWORD=admin123 + - ME_CONFIG_BASICAUTH_USERNAME=${MONGO_EXPRESS_USER:-admin} + - ME_CONFIG_BASICAUTH_PASSWORD=${MONGO_EXPRESS_PASSWORD:-changeme} - ME_CONFIG_MONGODB_ENABLE_ADMIN=true depends_on: - mongo @@ -72,6 +83,7 @@ services: volumes: mongo-data: + client_node_modules: networks: code-a2z-network: diff --git a/docs/DOCKER.md b/docs/DOCKER.md index ed448e47..3402cd30 100644 --- a/docs/DOCKER.md +++ b/docs/DOCKER.md @@ -748,10 +748,10 @@ sudo chown -R $USER:$USER . ```bash # Clear Docker cache and rebuild -docker-compose -f docker-compose.fullstack.yaml build --no-cache +docker-compose build --no-cache # Remove all containers and images -docker-compose -f docker-compose.fullstack.yaml down +docker-compose down docker system prune -a ``` diff --git a/server/.dockerignore b/server/.dockerignore index 6ecd9b3b..5576c198 100644 --- a/server/.dockerignore +++ b/server/.dockerignore @@ -2,7 +2,6 @@ node_modules npm-debug.log yarn-error.log -package-lock.json yarn.lock # Environment variables @@ -37,6 +36,7 @@ Thumbs.db # Docker Dockerfile +docker-compose*.yml docker-compose*.yaml .dockerignore diff --git a/server/Dockerfile b/server/Dockerfile index bd7c685a..a05f1aa5 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -29,7 +29,7 @@ WORKDIR /app COPY package*.json ./ # Install only production dependencies -RUN npm ci --only=production +RUN npm ci --omit=dev # Copy source code COPY . . diff --git a/server/docker-compose.yaml b/server/docker-compose.yaml index 2b39dbb9..cf55f5a0 100644 --- a/server/docker-compose.yaml +++ b/server/docker-compose.yaml @@ -21,7 +21,7 @@ services: - code-a2z-network mongo: - image: mongo:8.2.2-noble + image: mongo:7-noble container_name: code-a2z-mongo ports: - '27017:27017' @@ -38,8 +38,8 @@ services: - '8081:8081' environment: - ME_CONFIG_MONGODB_URL=mongodb://mongo:27017 - - ME_CONFIG_BASICAUTH_USERNAME=admin - - ME_CONFIG_BASICAUTH_PASSWORD=admin123 + - ME_CONFIG_BASICAUTH_USERNAME=${MONGO_EXPRESS_USER:-admin} + - ME_CONFIG_BASICAUTH_PASSWORD=${MONGO_EXPRESS_PASSWORD:-changeme} - ME_CONFIG_MONGODB_ENABLE_ADMIN=true depends_on: - mongo From c965989dbc3ba22610b6cb4160aa227f70450efa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:25:43 +0000 Subject: [PATCH 09/12] Add MONGO_EXPRESS credentials to server .env.example Co-authored-by: Avdhesh-Varshney <114330097+Avdhesh-Varshney@users.noreply.github.com> --- server/.env.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/.env.example b/server/.env.example index b5ec8cd5..06f32422 100644 --- a/server/.env.example +++ b/server/.env.example @@ -7,6 +7,10 @@ VITE_CLIENT_DOMAIN=https://code-a2z.vercel.app # Database Configuration MONGODB_URL=mongodb://localhost:27017/code-a2z +# Mongo Express Configuration (for Docker only) +MONGO_EXPRESS_USER=admin +MONGO_EXPRESS_PASSWORD=changeme + # Authentication Configuration JWT_SECRET_ACCESS_KEY= JWT_ACCESS_EXPIRES_IN=15m From 9d163c09c5a22709ab52a67a3c727dd42ba83c35 Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 22:17:57 +0530 Subject: [PATCH 10/12] update install command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7135ebfb..aa0cbd9c 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "test": "echo \"Error: no test specified\" && exit 1", "install:client": "cd client && npm install", "install:server": "cd server && npm install", - "install": "npm install && cd client && npm install && cd ../server && npm install", + "install:both": "npm install && cd client && npm install && cd ../server && npm install", "client": "cd client && npm run dev", "server": "cd server && npm run dev", "dev": "concurrently -n \"CLIENT,SERVER\" -c \"bgBlue.bold,bgMagenta.bold\" \"npm run client\" \"npm run server\"", From 33cc6de8600dace91d9f9726947ccc3858c0bf63 Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 22:20:10 +0530 Subject: [PATCH 11/12] format docker-compose file --- docker-compose.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 01a494a7..3ba36899 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -40,7 +40,15 @@ services: - ./server/logs:/app/logs restart: unless-stopped healthcheck: - test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8000/monitor/health"] + test: + [ + 'CMD', + 'wget', + '--no-verbose', + '--tries=1', + '--spider', + 'http://localhost:8000/monitor/health', + ] interval: 30s timeout: 10s retries: 3 @@ -57,7 +65,7 @@ services: - mongo-data:/data/db restart: unless-stopped healthcheck: - test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"] + test: ['CMD', 'mongosh', '--eval', "db.adminCommand('ping')"] interval: 10s timeout: 5s retries: 5 From fd86b554e479e1d19a5295c33e18f52588c0c9ab Mon Sep 17 00:00:00 2001 From: Avdhesh-Varshney Date: Thu, 20 Nov 2025 22:37:42 +0530 Subject: [PATCH 12/12] fixed mongodb version --- docker-compose.yaml | 2 +- server/docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 3ba36899..01e73cab 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -57,7 +57,7 @@ services: - code-a2z-network mongo: - image: mongo:7-noble + image: mongo:8-noble container_name: code-a2z-mongo ports: - '27017:27017' diff --git a/server/docker-compose.yaml b/server/docker-compose.yaml index cf55f5a0..eb6f2e82 100644 --- a/server/docker-compose.yaml +++ b/server/docker-compose.yaml @@ -21,7 +21,7 @@ services: - code-a2z-network mongo: - image: mongo:7-noble + image: mongo:8-noble container_name: code-a2z-mongo ports: - '27017:27017'