docker-compose.yml 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. version: "3.9"
  2. # ─────────────────────────────────────────────────────────────────────────────
  3. # PMDI – Pay My Damn Invoice
  4. # Multi-container Docker Compose orchestration
  5. # ─────────────────────────────────────────────────────────────────────────────
  6. services:
  7. # ── PostgreSQL 15 ──────────────────────────────────────────────────────────
  8. db:
  9. image: postgres:15-alpine
  10. container_name: pmdi_db
  11. restart: unless-stopped
  12. environment:
  13. POSTGRES_DB: ${POSTGRES_DB:-pmdi}
  14. POSTGRES_USER: ${POSTGRES_USER:-pmdi}
  15. POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
  16. volumes:
  17. - postgres_data:/var/lib/postgresql/data
  18. networks:
  19. - pmdi_net
  20. healthcheck:
  21. test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-pmdi} -d ${POSTGRES_DB:-pmdi}"]
  22. interval: 10s
  23. timeout: 5s
  24. retries: 5
  25. start_period: 15s
  26. # ── FastAPI Backend ────────────────────────────────────────────────────────
  27. backend:
  28. build:
  29. context: ./backend
  30. dockerfile: Dockerfile
  31. container_name: pmdi_backend
  32. restart: unless-stopped
  33. env_file:
  34. - .env
  35. environment:
  36. # Override DATABASE_URL so it always points to the db container
  37. DATABASE_URL: postgresql://${POSTGRES_USER:-pmdi}:${POSTGRES_PASSWORD:-changeme}@db:5432/${POSTGRES_DB:-pmdi}
  38. depends_on:
  39. db:
  40. condition: service_healthy
  41. ports:
  42. - "8000:8000"
  43. networks:
  44. - pmdi_net
  45. # ── Vue 3 Frontend ─────────────────────────────────────────────────────────
  46. frontend:
  47. build:
  48. context: ./frontend
  49. dockerfile: Dockerfile
  50. container_name: pmdi_frontend
  51. restart: unless-stopped
  52. environment:
  53. # Vite dev-server proxy target (must resolve inside the Docker network)
  54. VITE_API_TARGET: http://backend:8000
  55. ports:
  56. - "3000:3000"
  57. networks:
  58. - pmdi_net
  59. depends_on:
  60. - backend
  61. # ─── Optional: Postfix Mail Relay ─────────────────────────────────────────
  62. # Uncomment the block below to start an in-network mail relay (Mode B).
  63. # Then add MAIL_RELAY_HOST=postfix to your .env file so the backend
  64. # routes outbound mail through this container.
  65. #
  66. # postfix:
  67. # image: boky/postfix:latest
  68. # container_name: pmdi_postfix
  69. # restart: unless-stopped
  70. # environment:
  71. # ALLOWED_SENDER_DOMAINS: "${MAIL_SENDER_DOMAIN:-example.com}"
  72. # # Optional: forward to an upstream relay (e.g. Gmail SMTP)
  73. # # RELAYHOST: "[smtp.gmail.com]:587"
  74. # # RELAYHOST_USERNAME: "user@gmail.com"
  75. # # RELAYHOST_PASSWORD: "app-password"
  76. # networks:
  77. # - pmdi_net
  78. # ──────────────────────────────────────────────────────────────────────────
  79. # ── Volumes ────────────────────────────────────────────────────────────────
  80. volumes:
  81. postgres_data:
  82. driver: local
  83. # ── Networks ───────────────────────────────────────────────────────────────
  84. networks:
  85. pmdi_net:
  86. driver: bridge