docker-compose.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. version: '3.7'
  2. services:
  3. # ==========================================
  4. # Frontend (Vite Dev Server)
  5. # ==========================================
  6. frontend:
  7. build:
  8. context: ./frontend
  9. ports:
  10. - "5173:5173" # Vite default port
  11. depends_on:
  12. - backend
  13. # Hot Reload requires binding volume locally
  14. volumes:
  15. - ./frontend:/app
  16. - /app/node_modules # Avoid overwriting node_modules
  17. environment:
  18. # Browser needs to access backend directly for CORS requests in Dev mode
  19. - VITE_API_BASE_URL=http://localhost:8000/api/v1
  20. restart: always
  21. # ==========================================
  22. # Backend (FastAPI)
  23. # ==========================================
  24. backend:
  25. build:
  26. context: ./backend
  27. ports:
  28. - "8000:8000"
  29. environment:
  30. - MYSQL_SERVER=db
  31. - MYSQL_PORT=3306
  32. - MYSQL_USER=uap_user
  33. - MYSQL_PASSWORD=uap_pass
  34. - MYSQL_DB=uap_db
  35. - REDIS_HOST=redis
  36. - REDIS_PORT=6379
  37. - HYDRA_ADMIN_URL=http://hydra:4445
  38. # CORS: Add * to allow debugging from any origin if localhost fails
  39. # Also explictly allow 127.0.0.1 and localhost with port 5173
  40. - BACKEND_CORS_ORIGINS=["http://localhost:5173", "http://127.0.0.1:5173", "http://frontend:5173"]
  41. depends_on:
  42. db:
  43. condition: service_healthy
  44. redis:
  45. condition: service_healthy
  46. hydra:
  47. condition: service_started
  48. volumes:
  49. - ./backend:/app # Hot Reload for Backend too
  50. restart: always
  51. # ==========================================
  52. # Database (MySQL)
  53. # ==========================================
  54. db:
  55. image: mysql:8.0
  56. command: --default-authentication-plugin=mysql_native_password
  57. restart: always
  58. environment:
  59. MYSQL_ROOT_PASSWORD: root_password
  60. MYSQL_DATABASE: uap_db
  61. MYSQL_USER: uap_user
  62. MYSQL_PASSWORD: uap_pass
  63. ports:
  64. - "3308:3306"
  65. volumes:
  66. - db_data:/var/lib/mysql
  67. healthcheck:
  68. test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-u", "uap_user", "-p$$MYSQL_PASSWORD"]
  69. interval: 10s
  70. timeout: 5s
  71. retries: 10
  72. start_period: 10s
  73. # ==========================================
  74. # Redis
  75. # ==========================================
  76. redis:
  77. image: redis:alpine
  78. ports:
  79. - "6379:6379"
  80. restart: always
  81. healthcheck:
  82. test: ["CMD", "redis-cli", "ping"]
  83. interval: 10s
  84. timeout: 5s
  85. retries: 5
  86. # ==========================================
  87. # Ory Hydra Services
  88. # ==========================================
  89. hydra-migrate:
  90. image: oryd/hydra:v2.2.0
  91. environment:
  92. - DSN=postgres://hydra:secret@postgresd:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4
  93. command: migrate sql -e --yes
  94. depends_on:
  95. postgresd:
  96. condition: service_healthy
  97. restart: on-failure
  98. hydra:
  99. image: oryd/hydra:v2.2.0
  100. depends_on:
  101. hydra-migrate:
  102. condition: service_completed_successfully
  103. ports:
  104. - "4444:4444"
  105. - "4445:4445"
  106. - "5555:5555"
  107. command: serve -c /etc/config/hydra/hydra.yml all --dev
  108. environment:
  109. - DSN=postgres://hydra:secret@postgresd:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4
  110. - URLS_SELF_ISSUER=http://127.0.0.1:4444
  111. - URLS_CONSENT=http://localhost:5173/consent
  112. - URLS_LOGIN=http://localhost:5173/login
  113. - URLS_LOGOUT=http://localhost:5173/login
  114. - SECRETS_SYSTEM=youReallyNeedToChangeThis
  115. - OIDC_SUBJECT_IDENTIFIERS_SUPPORTED_TYPES=public,pairwise
  116. - OIDC_SUBJECT_IDENTIFIERS_PAIRWISE_SALT=youReallyNeedToChangeThis
  117. - SERVE_COOKIES_SAME_SITE_MODE=Lax
  118. - SERVE_COOKIES_SAME_SITE_LEGACY_WORKAROUND=true
  119. - SERVE_PUBLIC_CORS_ENABLED=true
  120. - SERVE_PUBLIC_CORS_ALLOWED_ORIGINS=*
  121. - SERVE_PUBLIC_CORS_ALLOWED_METHODS=POST,GET,PUT,DELETE,PATCH,OPTIONS
  122. - SERVE_PUBLIC_CORS_ALLOWED_HEADERS=Authorization,Content-Type
  123. - SERVE_ADMIN_CORS_ENABLED=true
  124. - SERVE_ADMIN_CORS_ALLOWED_ORIGINS=*
  125. postgresd:
  126. image: postgres:15
  127. environment:
  128. - POSTGRES_USER=hydra
  129. - POSTGRES_PASSWORD=secret
  130. - POSTGRES_DB=hydra
  131. volumes:
  132. - postgres_data:/var/lib/postgresql/data
  133. healthcheck:
  134. test: ["CMD-SHELL", "pg_isready -U hydra"]
  135. interval: 10s
  136. timeout: 5s
  137. retries: 5
  138. start_period: 10s
  139. volumes:
  140. db_data:
  141. postgres_data: