docker-compose.prod.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. postgres:
  20. <<: *common
  21. image: postgis/postgis:16-3.4-alpine
  22. environment:
  23. POSTGRES_DB: photoplaces
  24. POSTGRES_USER: photoplaces
  25. POSTGRES_PASSWORD_FILE: /run/secrets/db_password
  26. volumes:
  27. - pgdata:/var/lib/postgresql/data
  28. healthcheck:
  29. test: ["CMD-SHELL", "pg_isready -U photoplaces"]
  30. interval: 10s
  31. retries: 5
  32. secrets:
  33. - db_password
  34. redis:
  35. <<: *common
  36. image: redis:7-alpine
  37. command: redis-server --requirepass-file /run/secrets/redis_password
  38. volumes:
  39. - redisdata:/data
  40. healthcheck:
  41. test: ["CMD", "redis-cli", "-a", "$(cat /run/secrets/redis_password)", "ping"]
  42. interval: 10s
  43. retries: 5
  44. secrets:
  45. - redis_password
  46. minio:
  47. <<: *common
  48. image: minio/minio:latest
  49. command: server /data
  50. volumes:
  51. - miniodata:/data
  52. environment:
  53. MINIO_ROOT_USER: ${S3_ACCESS_KEY}
  54. MINIO_ROOT_PASSWORD_FILE: /run/secrets/s3_secret_key
  55. healthcheck:
  56. test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
  57. interval: 10s
  58. retries: 5
  59. secrets:
  60. - s3_secret_key
  61. backend:
  62. <<: *common
  63. build:
  64. context: ./backend
  65. dockerfile: Dockerfile
  66. ports:
  67. - "127.0.0.1:8080:8080"
  68. env_file:
  69. - ./env.prod
  70. environment:
  71. APP_ENV: production
  72. SERVER_PORT: "8080"
  73. DATABASE_URL: postgres://photoplaces:$(cat /run/secrets/db_password)@postgres:5432/photoplaces?sslmode=disable
  74. REDIS_URL: redis://:$(cat /run/secrets/redis_password)@redis:6379/0
  75. S3_ENDPOINT: http://minio:9000
  76. S3_PUBLIC_ENDPOINT: ${S3_PUBLIC_ENDPOINT}
  77. S3_ACCESS_KEY: ${S3_ACCESS_KEY}
  78. S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key
  79. S3_BUCKET: photoplaces
  80. JWT_SECRET_FILE: /run/secrets/jwt_secret
  81. JWT_REFRESH_SECRET_FILE: /run/secrets/jwt_refresh_secret
  82. CLOUDPAYMENTS_PUBLIC_ID: ${CLOUDPAYMENTS_PUBLIC_ID}
  83. CLOUDPAYMENTS_API_SECRET: ${CLOUDPAYMENTS_API_SECRET}
  84. ALLOWED_ORIGINS: ${ALLOWED_ORIGINS}
  85. depends_on:
  86. postgres:
  87. condition: service_healthy
  88. redis:
  89. condition: service_healthy
  90. minio:
  91. condition: service_healthy
  92. healthcheck:
  93. test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/api/v1/health"]
  94. interval: 30s
  95. timeout: 10s
  96. retries: 3
  97. start_period: 10s
  98. secrets:
  99. - db_password
  100. - redis_password
  101. - jwt_secret
  102. - jwt_refresh_secret
  103. - s3_secret_key
  104. frontend:
  105. <<: *common
  106. build:
  107. context: ./frontend
  108. dockerfile: Dockerfile
  109. args:
  110. NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
  111. NEXT_PUBLIC_MAP_PROVIDER: yandex
  112. NEXT_PUBLIC_YANDEX_MAPS_API_KEY: ${YANDEX_MAPS_API_KEY}
  113. ports:
  114. - "127.0.0.1:3000:3000"
  115. depends_on:
  116. backend:
  117. condition: service_healthy
  118. healthcheck:
  119. test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000"]
  120. interval: 30s
  121. timeout: 10s
  122. retries: 3
  123. start_period: 15s
  124. volumes:
  125. pgdata:
  126. redisdata:
  127. miniodata:
  128. networks:
  129. photoplaces:
  130. secrets:
  131. db_password:
  132. external: true
  133. redis_password:
  134. external: true
  135. jwt_secret:
  136. external: true
  137. jwt_refresh_secret:
  138. external: true
  139. s3_secret_key:
  140. external: true