ccccccc / docker-compose.dev.yml
cnmksjs's picture
Upload 49 files
24fd742 verified
version: '3.8'
services:
# MongoDB数据库
mongo:
image: mongo:7.0
container_name: chat-mongo-dev
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: password123
MONGO_INITDB_DATABASE: chatapp
ports:
- "27017:27017"
volumes:
- mongo_data_dev:/data/db
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
networks:
- chat-network-dev
# 后端开发服务
server-dev:
image: node:18-alpine
container_name: chat-server-dev
restart: unless-stopped
working_dir: /app
environment:
- NODE_ENV=development
- MONGODB_URI=mongodb://admin:password123@mongo:27017/chatapp?authSource=admin
- JWT_SECRET=dev-secret-key
- PORT=5000
- CLIENT_URL=http://localhost:3000
ports:
- "5000:5000"
depends_on:
- mongo
networks:
- chat-network-dev
volumes:
- ./server:/app
- /app/node_modules
command: sh -c "npm install && npm run dev"
# 前端开发服务
client-dev:
image: node:18-alpine
container_name: chat-client-dev
restart: unless-stopped
working_dir: /app
environment:
- VITE_API_URL=http://localhost:5000
ports:
- "3000:3000"
depends_on:
- server-dev
networks:
- chat-network-dev
volumes:
- ./client:/app
- /app/node_modules
command: sh -c "npm install && npm run dev"
volumes:
mongo_data_dev:
networks:
chat-network-dev:
driver: bridge