docker-compose.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. version: '3.8'
  2. services:
  3. # PostgreSQL 数据库
  4. postgres:
  5. image: postgres:15-alpine
  6. container_name: vue3-admin-postgres
  7. restart: unless-stopped
  8. environment:
  9. POSTGRES_DB: vue3_admin
  10. POSTGRES_USER: postgres
  11. POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-123456}
  12. volumes:
  13. - postgres_data:/var/lib/postgresql/data
  14. - ./postgreSQL:/docker-entrypoint-initdb.d
  15. ports:
  16. - "5432:5432"
  17. networks:
  18. - vue3-admin-network
  19. healthcheck:
  20. test: ["CMD-SHELL", "pg_isready -U postgres"]
  21. interval: 30s
  22. timeout: 10s
  23. retries: 3
  24. # 主应用服务(前端 + 后端)
  25. app:
  26. build:
  27. context: .
  28. dockerfile: Dockerfile
  29. container_name: vue3-admin-app
  30. restart: unless-stopped
  31. ports:
  32. - "80:80"
  33. - "6666:6666"
  34. environment:
  35. - NODE_ENV=production
  36. - DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD:-123456}@postgres:5432/vue3_admin
  37. - JWT_SECRET=${JWT_SECRET:-your-jwt-secret-key-here}
  38. - SESSION_SECRET=${SESSION_SECRET:-your-session-secret-key-here}
  39. volumes:
  40. - ./server/upload:/app/server/upload
  41. - app_logs:/app/logs
  42. depends_on:
  43. postgres:
  44. condition: service_healthy
  45. networks:
  46. - vue3-admin-network
  47. healthcheck:
  48. test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:6666/health"]
  49. interval: 30s
  50. timeout: 10s
  51. retries: 3
  52. networks:
  53. vue3-admin-network:
  54. driver: bridge
  55. volumes:
  56. postgres_data:
  57. driver: local
  58. app_logs:
  59. driver: local