docker-compose.prod.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. version: "3.9"
  2. x-common: &common
  3. restart: unless-stopped
  4. networks:
  5. - photoplaces
  6. # Secrets for Docker Swarm mode (optional, ignored in compose)
  7. x-secrets: &secrets
  8. db_password:
  9. external: true
  10. redis_password:
  11. external: true
  12. jwt_secret:
  13. external: true
  14. jwt_refresh_secret:
  15. external: true
  16. s3_secret_key:
  17. external: true
  18. services:
  19. caddy:
  20. <<: *common
  21. image: caddy:2.8-alpine
  22. ports:
  23. - "80:80"
  24. - "443:443"
  25. volumes:
  26. - ./Caddyfile:/etc/caddy/Caddyfile
  27. - caddy_data:/data
  28. - caddy_config:/config
  29. environment:
  30. DOMAIN: ${DOMAIN}
  31. MINIO_CONSOLE_USER: ${MINIO_CONSOLE_USER:-admin}
  32. MINIO_CONSOLE_PASSWORD: ${MINIO_CONSOLE_PASSWORD}
  33. depends_on:
  34. backend:
  35. condition: service_healthy
  36. frontend:
  37. condition: service_healthy
  38. healthcheck:
  39. test: ["CMD", "wget", "-q", "--spider", "http://localhost:2019/metrics"]
  40. interval: 30s
  41. timeout: 10s
  42. retries: 3
  43. start_period: 10s
  44. postgres:
  45. <<: *common
  46. image: postgis/postgis:16-3.4-alpine
  47. environment:
  48. POSTGRES_DB: photoplaces
  49. POSTGRES_USER: photoplaces
  50. POSTGRES_PASSWORD_FILE: /run/secrets/db_password
  51. volumes:
  52. - pgdata:/var/lib/postgresql/data
  53. healthcheck:
  54. test: ["CMD-SHELL", "pg_isready -U photoplaces"]
  55. interval: 10s
  56. retries: 5
  57. secrets:
  58. - db_password
  59. redis:
  60. <<: *common
  61. image: redis:7-alpine
  62. command: redis-server --requirepass-file /run/secrets/redis_password
  63. volumes:
  64. - redisdata:/data
  65. healthcheck:
  66. test: ["CMD", "redis-cli", "-a", "$(cat /run/secrets/redis_password)", "ping"]
  67. interval: 10s
  68. retries: 5
  69. secrets:
  70. - redis_password
  71. minio:
  72. <<: *common
  73. image: minio/minio:latest
  74. command: server /data
  75. volumes:
  76. - miniodata:/data
  77. environment:
  78. MINIO_ROOT_USER: ${S3_ACCESS_KEY}
  79. MINIO_ROOT_PASSWORD_FILE: /run/secrets/s3_secret_key
  80. healthcheck:
  81. test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
  82. interval: 10s
  83. retries: 5
  84. secrets:
  85. - s3_secret_key
  86. backend:
  87. <<: *common
  88. build:
  89. context: ./backend
  90. dockerfile: Dockerfile
  91. env_file:
  92. - ./env.prod
  93. environment:
  94. APP_ENV: production
  95. SERVER_PORT: "8080"
  96. DATABASE_URL: postgres://photoplaces:$(cat /run/secrets/db_password)@postgres:5432/photoplaces?sslmode=disable
  97. REDIS_URL: redis://:$(cat /run/secrets/redis_password)@redis:6379/0
  98. S3_ENDPOINT: http://minio:9000
  99. S3_PUBLIC_ENDPOINT: ${S3_PUBLIC_ENDPOINT}
  100. S3_ACCESS_KEY: ${S3_ACCESS_KEY}
  101. S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key
  102. S3_BUCKET: photoplaces
  103. JWT_SECRET_FILE: /run/secrets/jwt_secret
  104. JWT_REFRESH_SECRET_FILE: /run/secrets/jwt_refresh_secret
  105. CLOUDPAYMENTS_PUBLIC_ID: ${CLOUDPAYMENTS_PUBLIC_ID}
  106. CLOUDPAYMENTS_API_SECRET: ${CLOUDPAYMENTS_API_SECRET}
  107. ALLOWED_ORIGINS: ${ALLOWED_ORIGINS}
  108. depends_on:
  109. postgres:
  110. condition: service_healthy
  111. redis:
  112. condition: service_healthy
  113. minio:
  114. condition: service_healthy
  115. healthcheck:
  116. test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/api/v1/health"]
  117. interval: 30s
  118. timeout: 10s
  119. retries: 3
  120. start_period: 10s
  121. secrets:
  122. - db_password
  123. - redis_password
  124. - jwt_secret
  125. - jwt_refresh_secret
  126. - s3_secret_key
  127. frontend:
  128. <<: *common
  129. build:
  130. context: ./frontend
  131. dockerfile: Dockerfile
  132. args:
  133. NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
  134. NEXT_PUBLIC_MAP_PROVIDER: yandex
  135. NEXT_PUBLIC_YANDEX_MAPS_API_KEY: ${YANDEX_MAPS_API_KEY}
  136. depends_on:
  137. backend:
  138. condition: service_healthy
  139. healthcheck:
  140. test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000"]
  141. interval: 30s
  142. timeout: 10s
  143. retries: 3
  144. start_period: 15s
  145. volumes:
  146. pgdata:
  147. redisdata:
  148. miniodata:
  149. caddy_data:
  150. caddy_config:
  151. networks:
  152. photoplaces:
  153. secrets:
  154. db_password:
  155. external: true
  156. redis_password:
  157. external: true
  158. jwt_secret:
  159. external: true
  160. jwt_refresh_secret:
  161. external: true
  162. s3_secret_key:
  163. external: true