docker-compose.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. version: '3.7'
  2. # Environment variables are replaced with definitions in .env, when run with:
  3. #
  4. # env $(cat .env | grep ^[A-Z] | xargs) docker stack deploy --compose-file docker-compose.yml server
  5. networks:
  6. default:
  7. driver: overlay
  8. volumes:
  9. traefik-certs: {}
  10. services:
  11. traefik:
  12. image: traefik:v2.6.6
  13. ports:
  14. - 80:80
  15. - 443:443
  16. deploy:
  17. #replicas: 2 # https://youtu.be/btHpHjabRcc
  18. placement:
  19. constraints:
  20. - node.role == manager
  21. labels:
  22. - traefik.enable=true
  23. # Enable the dashboard UI
  24. - traefik.http.routers.api.rule=Host(`board.${DOMAIN}`)
  25. - traefik.http.routers.api.service=api@internal
  26. - traefik.http.routers.api.middlewares=auth
  27. - traefik.http.routers.api.tls=true
  28. - "traefik.http.middlewares.auth.basicauth.users=${TRAEFIK_API_USERS}"
  29. # Dummy service for Swarm port detection. The port can be any valid integer value.
  30. - traefik.http.services.dummy-svc.loadbalancer.server.port=9999
  31. - traefik.http.routers.traefik.tls=true
  32. # Use LS to get/renew certs for the TLD & subdomains
  33. - traefik.http.routers.traefik.tls.certresolver=le
  34. - traefik.http.routers.traefik.tls.domains[0].main=${DOMAIN}
  35. - traefik.http.routers.traefik.tls.domains[0].sans=*.${DOMAIN}
  36. volumes:
  37. - /var/run/docker.sock:/var/run/docker.sock:ro
  38. - ${CONTAINERS_DIR}/traefik/static.toml:/static.toml
  39. # cert storage can't be shared: https://doc.traefik.io/traefik/https/acme/#storage
  40. - traefik-certs:/certificates
  41. command:
  42. # Require a "traefik.enable=true" label
  43. - --providers.docker.exposedbydefault=false
  44. - --providers.docker.swarmmode=true
  45. # HTTP redirects to HTTPS
  46. - --entrypoints.web.address=:80
  47. - --entrypoints.web.http.redirections.entrypoint.permanent=false
  48. - --entrypoints.web.http.redirections.entryPoint.to=websecure
  49. - --entrypoints.web.http.redirections.entryPoint.scheme=https
  50. - --entrypoints.websecure.address=:443
  51. # Auto cert renewal via cloudflare
  52. - --certificatesresolvers.le.acme.email=${LETSENCRYPT_EMAIL}
  53. - --certificatesresolvers.le.acme.storage=/certificates/acme.json
  54. - --certificatesresolvers.le.acme.dnschallenge.provider=cloudflare
  55. - --certificatesresolvers.le.acme.dnschallenge.resolvers=1.1.1.1:53,8.8.8.8:53
  56. # debug, uncomment for testing
  57. #- --certificatesresolvers.le.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory
  58. #- --log.level=DEBUG
  59. - --accesslog=true
  60. - --log=true
  61. # Enable the traefik dashboard
  62. - --api=true
  63. - --providers.file.filename=/static.toml
  64. environment:
  65. - CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL}
  66. - CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY}
  67. #jekyll:
  68. # image: jibby0/docker-jekyll-webhook:test
  69. # deploy:
  70. # placement:
  71. # # TODO I don't know why the 2nd replica 502s all the time if I don't do this
  72. # constraints:
  73. # - node.labels.cpu-intensive == true
  74. # replicas: 2
  75. # labels:
  76. # - traefik.enable=true
  77. # - traefik.http.routers.jekyll.tls=true
  78. # - traefik.http.routers.jekyll.rule=Host(`${DOMAIN}`)
  79. # - traefik.http.services.jekyll.loadbalancer.server.port=80
  80. # environment:
  81. # - TZ=America/New_York
  82. # - WEBHOOK_SECRET=${WEBHOOK_SECRET}
  83. # - REPO=https://github.com/jibby0/blog.git
  84. # restart: always
  85. # volumes:
  86. # - ${CONTAINERS_DIR}/jekyll/vendor_cache:/vendor
  87. # postgres:
  88. # image: postgres:13.2
  89. # deploy:
  90. # placement:
  91. # constraints:
  92. # - node.labels.cpu-intensive == true
  93. # volumes:
  94. # - ${CONTAINERS_DIR}/postgres/data:/var/lib/postgresql/data
  95. # - ${CONTAINERS_DIR}/postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
  96. # environment:
  97. # - POSTGRES_USER=${POSTGRES_USER}
  98. # - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
  99. # restart: always
  100. #nextcloud:
  101. # image: nextcloud:23.0.0
  102. # deploy:
  103. # placement:
  104. # constraints:
  105. # - node.labels.cpu-intensive == true
  106. # labels:
  107. # - traefik.enable=true
  108. # - traefik.http.routers.nextcloud.tls=true
  109. # - traefik.http.routers.nextcloud.rule=Host(`nextcloud.${DOMAIN}`)
  110. # - traefik.http.services.nextcloud.loadbalancer.server.port=80
  111. # expose:
  112. # - "80"
  113. # links:
  114. # - postgres
  115. # - redis
  116. # volumes:
  117. # - ${CONTAINERS_DIR}/nextcloud:/var/www/html
  118. # environment:
  119. # - REDIS_HOST=redis
  120. # restart: always
  121. #redis:
  122. # image: redis:6.2.6
  123. # deploy:
  124. # placement:
  125. # constraints:
  126. # - node.labels.cpu-intensive == true
  127. # command: redis-server --save 60 1 --loglevel warning
  128. # volumes:
  129. # - ${CONTAINERS_DIR}/redis:/data
  130. # restart: always
  131. # gogs:
  132. # image: gogs/gogs:0.12.0
  133. # deploy:
  134. # labels:
  135. # - traefik.enable=true
  136. # - traefik.http.routers.gogs.tls=true
  137. # - traefik.http.routers.gogs.rule=Host(`gogs.${DOMAIN}`)
  138. # - traefik.http.services.gogs.loadbalancer.server.port=3000
  139. # expose:
  140. # - "3000"
  141. # volumes:
  142. # - ${CONTAINERS_DIR}/gogs:/data
  143. # # NOTE: My gogs instance isn't happy with postgres. For now, it's a small server
  144. # # and sqlite is fine, but I should fix this eventually.
  145. # #links:
  146. # # - postgres
  147. # restart: always
  148. # matrix:
  149. # image: matrixdotorg/synapse:v1.55.2
  150. # deploy:
  151. # placement:
  152. # constraints:
  153. # - node.labels.cpu-intensive == true
  154. # labels:
  155. # - traefik.enable=true
  156. # - traefik.http.routers.matrix.tls=true
  157. # - traefik.http.routers.matrix.rule=Host(`matrix.${DOMAIN}`)
  158. # - traefik.http.services.matrix.loadbalancer.server.port=8008
  159. # expose:
  160. # - "8008"
  161. # links:
  162. # - postgres
  163. # volumes:
  164. # - ${CONTAINERS_DIR}/matrix:/data
  165. # restart: always
  166. # matrix_wellknown:
  167. # image: adrianrudnik/matrix-wellknown-server:1.0.1
  168. # volumes:
  169. # - ${CONTAINERS_DIR}/matrix/wellknown:/var/schema
  170. # deploy:
  171. # labels:
  172. # - traefik.enable=true
  173. # - traefik.http.routers.matrix-wellknown.tls=true
  174. # - traefik.http.routers.matrix-wellknown.rule=Host(`matrix.${DOMAIN}`) && PathPrefix(`/.well-known/matrix/`)
  175. # - traefik.http.services.matrix-wellknown.loadbalancer.server.port=8080
  176. # expose:
  177. # - "8080"
  178. # selfoss:
  179. # image: jibby0/selfoss:2.18
  180. # deploy:
  181. # # TODO `postgres` is only accesssible on the same node ????
  182. # placement:
  183. # constraints:
  184. # - node.labels.media-encoding == true
  185. # labels:
  186. # - traefik.enable=true
  187. # - traefik.http.routers.selfoss.tls=true
  188. # - traefik.http.routers.selfoss.rule=Host(`selfoss.${DOMAIN}`)
  189. # - traefik.http.services.selfoss.loadbalancer.server.port=8888
  190. # expose:
  191. # - "8888"
  192. # links:
  193. # - postgres
  194. # volumes:
  195. # - ${CONTAINERS_DIR}/selfoss:/selfoss/data
  196. # environment:
  197. # - CRON_PERIOD=5m
  198. # restart: always