docker-compose.yml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. version: '3.4'
  2. services:
  3. # mongodb:
  4. # image: bitnami/mongodb:latest
  5. # ports:
  6. # - "27017"
  7. # volumes:
  8. # - data:/bitnami/mongodb
  9. # redis:
  10. # image: redis:6.2-alpine
  11. # hostname: redis
  12. # container_name: redis
  13. # command:
  14. # - 'redis-server'
  15. # - '--requirepass myStrongPassword'
  16. # ports:
  17. # - 36379:6379
  18. # restart: always
  19. # deploy:
  20. # placement:
  21. # constraints:
  22. # - "node.labels.type==queue"
  23. # restart_policy:
  24. # condition: on-failure
  25. # delay: 5s
  26. # max_attempts: 3
  27. # window: 120s
  28. # update_config:
  29. # parallelism: 2
  30. # delay: 10s
  31. # order: stop-first
  32. # rollback_config:
  33. # parallelism: 2
  34. # delay: 10s
  35. # order: stop-first
  36. nginx:
  37. image: nginx:1.17
  38. volumes:
  39. - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
  40. command: '/bin/sh -c ''while :; do sleep 336h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
  41. ports:
  42. - 80:80
  43. - 443:443
  44. depends_on:
  45. - backend
  46. - frontend
  47. deploy:
  48. placement:
  49. constraints:
  50. - node.role == manager
  51. restart_policy:
  52. condition: on-failure
  53. delay: 5s
  54. max_attempts: 3
  55. window: 120s
  56. update_config:
  57. parallelism: 2
  58. delay: 10s
  59. order: stop-first
  60. rollback_config:
  61. parallelism: 2
  62. delay: 10s
  63. order: stop-first
  64. resources:
  65. limits:
  66. cpus: '0.20'
  67. memory: 100M
  68. reservations:
  69. cpus: '0.05'
  70. memory: 20M
  71. ports:
  72. - 80:80
  73. - 443:443
  74. # certbot:
  75. # container_name: certbot
  76. # entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 118h & wait $${!}; done;'"
  77. # image: certbot/certbot
  78. # volumes:
  79. # - ./docker/nginx/certbot/conf:/etc/letsencrypt
  80. # - ./docker/nginx/certbot/www:/var/www/certbot
  81. # rabbitmq:
  82. # image: rabbitmq:3.8.4-management
  83. # container_name: rabbitmq
  84. # env_file:
  85. # - .prod.env
  86. # volumes:
  87. # - ./docker/rabbitmq/etc/:/etc/rabbitmq/
  88. # - ./docker/rabbitmq/data/:/var/lib/rabbitmq/
  89. # - ./docker/rabbitmq/logs/:/var/log/rabbitmq/
  90. # ports:
  91. # - 5672
  92. # - 15672
  93. # deploy:
  94. # placement:
  95. # constraints:
  96. # - "node.labels.type==queue"
  97. # restart_policy:
  98. # condition: on-failure
  99. # delay: 5s
  100. # max_attempts: 3
  101. # window: 120s
  102. # update_config:
  103. # parallelism: 2
  104. # delay: 10s
  105. # order: stop-first
  106. # rollback_config:
  107. # parallelism: 2
  108. # delay: 10s
  109. # order: stop-first
  110. db:
  111. container_name: db
  112. image: postgres:12
  113. restart: always
  114. volumes:
  115. - app-db-data:/var/lib/postgresql/data/pgdata
  116. env_file:
  117. - .env
  118. networks:
  119. - traefik-public
  120. environment:
  121. - PGDATA=/var/lib/postgresql/data/pgdata
  122. - POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
  123. - POSTGRES_USER=${POSTGRES_USER?Variable not set}
  124. - POSTGRES_DB=${POSTGRES_DB?Variable not set}
  125. adminer:
  126. container_name: db-adminer
  127. image: adminer
  128. restart: always
  129. networks:
  130. - traefik-public
  131. depends_on:
  132. - db
  133. environment:
  134. - ADMINER_DESIGN=pepa-linha-dark
  135. labels:
  136. - traefik.enable=true
  137. - traefik.docker.network=traefik-public
  138. - traefik.constraint-label=traefik-public
  139. - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-http.rule=Host(`adminer.${DOMAIN?Variable not set}`)
  140. - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-http.entrypoints=http
  141. - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-http.middlewares=https-redirect
  142. - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-https.rule=Host(`adminer.${DOMAIN?Variable not set}`)
  143. - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-https.entrypoints=https
  144. - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-https.tls=true
  145. - traefik.http.routers.${STACK_NAME?Variable not set}-adminer-https.tls.certresolver=le
  146. - traefik.http.services.${STACK_NAME?Variable not set}-adminer.loadbalancer.server.port=8080
  147. ports:
  148. - 8081:8080
  149. backend:
  150. container_name: backend
  151. image: 'jianboy/${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
  152. # build:
  153. # context: ./backend
  154. # dockerfile: ./Dockerfile
  155. restart: always
  156. networks:
  157. - traefik-public
  158. depends_on:
  159. - db
  160. ports:
  161. - 8080:8080
  162. - 8000:8000
  163. env_file:
  164. - .env
  165. environment:
  166. - DOMAIN=${DOMAIN}
  167. - ENVIRONMENT=${ENVIRONMENT}
  168. - BACKEND_CORS_ORIGINS=${BACKEND_CORS_ORIGINS}
  169. - SECRET_KEY=${SECRET_KEY?Variable not set}
  170. - FIRST_SUPERUSER=${FIRST_SUPERUSER?Variable not set}
  171. - FIRST_SUPERUSER_PASSWORD=${FIRST_SUPERUSER_PASSWORD?Variable not set}
  172. - USERS_OPEN_REGISTRATION=${USERS_OPEN_REGISTRATION}
  173. - SMTP_HOST=${SMTP_HOST}
  174. - SMTP_USER=${SMTP_USER}
  175. - SMTP_PASSWORD=${SMTP_PASSWORD}
  176. - EMAILS_FROM_EMAIL=${EMAILS_FROM_EMAIL}
  177. - POSTGRES_SERVER=db
  178. - POSTGRES_PORT=${POSTGRES_PORT}
  179. - POSTGRES_DB=${POSTGRES_DB}
  180. - POSTGRES_USER=${POSTGRES_USER?Variable not set}
  181. - POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
  182. - SENTRY_DSN=${SENTRY_DSN}
  183. deploy:
  184. mode: replicated
  185. replicas: 4
  186. restart_policy:
  187. condition: on-failure
  188. delay: 5s
  189. max_attempts: 3
  190. window: 120s
  191. update_config:
  192. parallelism: 2
  193. delay: 10s
  194. order: stop-first
  195. rollback_config:
  196. parallelism: 2
  197. delay: 10s
  198. order: stop-first
  199. resources:
  200. limits:
  201. cpus: '0.50'
  202. memory: 150M
  203. reservations:
  204. cpus: '0.20'
  205. memory: 40M
  206. # build:
  207. # context: ./backend
  208. # args:
  209. # INSTALL_DEV: ${INSTALL_DEV-false}
  210. # platform: linux/amd64 # Patch for M1 Mac
  211. # labels:
  212. # - traefik.enable=true
  213. # - traefik.docker.network=traefik-public
  214. # - traefik.constraint-label=traefik-public
  215. # - traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=80
  216. # - traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=Host(`${DOMAIN?Variable not set}`, `www.${DOMAIN?Variable not set}`) && PathPrefix(`/api`, `/docs`, `/redoc`)
  217. # - traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.entrypoints=http
  218. # - traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.rule=Host(`${DOMAIN?Variable not set}`, `www.${DOMAIN?Variable not set}`) && PathPrefix(`/api`, `/docs`, `/redoc`)
  219. # - traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.entrypoints=https
  220. # - traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.tls=true
  221. # - traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.tls.certresolver=le
  222. # - traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.middlewares=https-redirect,${STACK_NAME?Variable not set}-www-redirect
  223. # - traefik.http.routers.${STACK_NAME?Variable not set}-backend-https.middlewares=${STACK_NAME?Variable not set}-www-redirect
  224. # frontend:
  225. # container_name: frontend
  226. # image: 'jianboy/${DOCKER_IMAGE_FRONTEND?Variable not set}:${TAG-latest}'
  227. # restart: always
  228. # networks:
  229. # - traefik-public
  230. # build:
  231. # context: ./frontend
  232. # args:
  233. # - VITE_API_URL=https://${DOMAIN?Variable not set}
  234. # - NODE_ENV=production
  235. # labels:
  236. # - traefik.enable=true
  237. # - traefik.docker.network=traefik-public
  238. # - traefik.constraint-label=traefik-public
  239. # - traefik.http.services.${STACK_NAME?Variable not set}-frontend.loadbalancer.server.port=80
  240. # - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.rule=Host(`${DOMAIN?Variable not set}`, `www.${DOMAIN?Variable not set}`)
  241. # - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.entrypoints=http
  242. # - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.rule=Host(`${DOMAIN?Variable not set}`, `www.${DOMAIN?Variable not set}`)
  243. # - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.entrypoints=https
  244. # - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.tls=true
  245. # - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.tls.certresolver=le
  246. # # Handle domain with and without "www" to redirect to only one
  247. # # To disable www redirection remove the next line
  248. # - traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.regex=^http(s)?://www.(${DOMAIN?Variable not set})/(.*)
  249. # # Redirect a domain with www to non-www
  250. # # To disable it remove the next line
  251. # - traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.replacement=http$${1}://${DOMAIN?Variable not set}/$${3}
  252. # # Middleware to redirect www, to disable it remove the next line
  253. # - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-https.middlewares=${STACK_NAME?Variable not set}-www-redirect
  254. # # Middleware to redirect www, and redirect HTTP to HTTPS
  255. # # to disable www redirection remove the section: ${STACK_NAME?Variable not set}-www-redirect,
  256. # - traefik.http.routers.${STACK_NAME?Variable not set}-frontend-http.middlewares=https-redirect,${STACK_NAME?Variable not set}-www-redirect
  257. volumes:
  258. app-db-data:
  259. networks:
  260. traefik-public: # external: true