local-docker-compose.yml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. version: "3.3"
  2. services:
  3. proxy:
  4. image: traefik:v2.9
  5. networks:
  6. - ${TRAEFIK_PUBLIC_NETWORK?Variable not set}
  7. - default
  8. volumes:
  9. - /var/run/docker.sock:/var/run/docker.sock
  10. command:
  11. # Enable Docker in Traefik, so that it reads labels from Docker services
  12. - --providers.docker
  13. # Add a constraint to only use services with the label for this stack
  14. # from the env var TRAEFIK_TAG
  15. - --providers.docker.constraints=Label(`traefik.constraint-label-stack`, `${TRAEFIK_TAG?Variable not set}`)
  16. # Do not expose all Docker services, only the ones explicitly exposed
  17. - --providers.docker.exposedbydefault=false
  18. # Enable Docker Swarm mode
  19. - --providers.docker.swarmmode
  20. # Enable the access log, with HTTP requests
  21. - --accesslog
  22. # Enable the Traefik log, for configurations and errors
  23. - --log
  24. # Enable the Dashboard and API
  25. - --api
  26. deploy:
  27. placement:
  28. constraints:
  29. - node.role == manager
  30. labels:
  31. # Enable Traefik for this service, to make it available in the public network
  32. - traefik.enable=true
  33. # Use the traefik-public network (declared below)
  34. - traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
  35. # Use the custom label "traefik.constraint-label=traefik-public"
  36. # This public Traefik will only use services with this label
  37. - traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
  38. # traefik-http set up only to use the middleware to redirect to https
  39. - traefik.http.middlewares.${STACK_NAME?Variable not set}-https-redirect.redirectscheme.scheme=https
  40. - traefik.http.middlewares.${STACK_NAME?Variable not set}-https-redirect.redirectscheme.permanent=true
  41. # Handle host with and without "www" to redirect to only one of them
  42. # Uses environment variable DOMAIN
  43. # To disable www redirection remove the Host() you want to discard, here and
  44. # below for HTTPS
  45. - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
  46. - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.entrypoints=http
  47. # traefik-https the actual router using HTTPS
  48. - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.rule=Host(`${DOMAIN?Variable not set}`) || Host(`www.${DOMAIN?Variable not set}`)
  49. - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.entrypoints=https
  50. - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.tls=true
  51. # Use the "le" (Let's Encrypt) resolver created below
  52. - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.tls.certresolver=le
  53. # Define the port inside of the Docker service to use
  54. - traefik.http.services.${STACK_NAME?Variable not set}-proxy.loadbalancer.server.port=80
  55. # Handle domain with and without "www" to redirect to only one
  56. # To disable www redirection remove the next line
  57. - traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.regex=^https?://(www.)?(${DOMAIN?Variable not set})/(.*)
  58. # Redirect a domain with www to non-www
  59. # To disable it remove the next line
  60. - traefik.http.middlewares.${STACK_NAME?Variable not set}-www-redirect.redirectregex.replacement=https://${DOMAIN?Variable not set}/$${3}
  61. # Redirect a domain without www to www
  62. # To enable it remove the previous line and uncomment the next
  63. # - traefik.http.middlewares.${STACK_NAME}-www-redirect.redirectregex.replacement=https://www.${DOMAIN}/$${3}
  64. # Middleware to redirect www, to disable it remove the next line
  65. - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-https.middlewares=${STACK_NAME?Variable not set}-www-redirect
  66. # Middleware to redirect www, and redirect HTTP to HTTPS
  67. # to disable www redirection remove the section: ${STACK_NAME?Variable not set}-www-redirect,
  68. - traefik.http.routers.${STACK_NAME?Variable not set}-proxy-http.middlewares=${STACK_NAME?Variable not set}-www-redirect,${STACK_NAME?Variable not set}-https-redirect
  69. queue:
  70. image: rabbitmq:3
  71. # Using the below image instead is required to enable the "Broker" tab in the flower UI:
  72. # image: rabbitmq:3-management
  73. #
  74. # You also have to change the flower command
  75. flower:
  76. image: mher/flower:0.9.7
  77. networks:
  78. - ${TRAEFIK_PUBLIC_NETWORK?Variable not set}
  79. - default
  80. env_file:
  81. - .env
  82. command:
  83. - "--broker=amqp://guest@queue:5672//"
  84. # For the "Broker" tab to work in the flower UI, uncomment the following command argument,
  85. # and change the queue service's image as well
  86. # - "--broker_api=http://guest:guest@queue:15672/api//"
  87. deploy:
  88. labels:
  89. - traefik.enable=true
  90. - traefik.docker.network=${TRAEFIK_PUBLIC_NETWORK?Variable not set}
  91. - traefik.constraint-label=${TRAEFIK_PUBLIC_TAG?Variable not set}
  92. - traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.rule=Host(`flower.${DOMAIN?Variable not set}`)
  93. - traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.entrypoints=http
  94. - traefik.http.routers.${STACK_NAME?Variable not set}-flower-http.middlewares=${STACK_NAME?Variable not set}-https-redirect
  95. - traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.rule=Host(`flower.${DOMAIN?Variable not set}`)
  96. - traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.entrypoints=https
  97. - traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.tls=true
  98. - traefik.http.routers.${STACK_NAME?Variable not set}-flower-https.tls.certresolver=le
  99. - traefik.http.services.${STACK_NAME?Variable not set}-flower.loadbalancer.server.port=5555
  100. backend:
  101. image: '${DOCKER_IMAGE_BACKEND?Variable not set}:${TAG-latest}'
  102. env_file:
  103. - .env
  104. environment:
  105. - SERVER_NAME=${DOMAIN?Variable not set}
  106. - SERVER_HOST=https://${DOMAIN?Variable not set}
  107. # Allow explicit env var override for tests
  108. - SMTP_HOST=${SMTP_HOST}
  109. build:
  110. context: ./backend
  111. dockerfile: backend.dockerfile
  112. args:
  113. INSTALL_DEV: ${INSTALL_DEV-false}
  114. deploy:
  115. labels:
  116. - traefik.enable=true
  117. - traefik.constraint-label-stack=${TRAEFIK_TAG?Variable not set}
  118. - traefik.http.routers.${STACK_NAME?Variable not set}-backend-http.rule=PathPrefix(`/api`) || PathPrefix(`/docs`) || PathPrefix(`/redoc`)
  119. - traefik.http.services.${STACK_NAME?Variable not set}-backend.loadbalancer.server.port=80
  120. gpuceleryworker:
  121. image: '${DOCKER_IMAGE_CELERYWORKER?Variable not set}:${TAG-latest}'
  122. depends_on:
  123. - queue
  124. env_file:
  125. - .env
  126. environment:
  127. - SERVER_NAME=${DOMAIN?Variable not set}
  128. - SERVER_HOST=https://${DOMAIN?Variable not set}
  129. # Allow explicit env var override for tests
  130. - SMTP_HOST=${SMTP_HOST?Variable not set}
  131. build:
  132. context: ./backend
  133. dockerfile: gpuceleryworker.dockerfile
  134. args:
  135. INSTALL_DEV: ${INSTALL_DEV-false}
  136. networks:
  137. traefik-public:
  138. # Allow setting it to false for testing
  139. external: true