docker-compose.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. version: '3.9'
  2. x-common-environment:
  3. &common-environment
  4. TZ: Asia/Shanghai
  5. x-common-config:
  6. &common-config
  7. restart: unless-stopped
  8. networks:
  9. - app-tier
  10. environment:
  11. <<: *common-environment
  12. deploy:
  13. resources:
  14. limits:
  15. cpus: '2'
  16. memory: '1G'
  17. services:
  18. postgres:
  19. image: postgres:${POSTGRES_VERSION}
  20. container_name: postgres
  21. <<: *common-config
  22. environment:
  23. <<: *common-environment
  24. POSTGRES_USER: ${POSTGRES_USER}
  25. POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
  26. PGDATA: /var/lib/postgresql/data/pgdata
  27. POSTGRES_INITDB_ARGS: "--data-checksums"
  28. POSTGRES_POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
  29. command: >
  30. postgres
  31. -c shared_buffers=1GB
  32. -c work_mem=16MB
  33. -c maintenance_work_mem=128MB
  34. -c effective_cache_size=768MB
  35. -c random_page_cost=1.1
  36. -c synchronous_commit=off
  37. -c wal_buffers=16MB
  38. -c max_connections=200
  39. -c checkpoint_completion_target=0.9
  40. -c min_wal_size=80MB
  41. -c max_wal_size=1GB
  42. volumes:
  43. - ./postgresql/data:/var/lib/postgresql/data
  44. ports:
  45. - "5432:5432"
  46. healthcheck:
  47. test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
  48. interval: 30s
  49. timeout: 10s
  50. retries: 5
  51. redis:
  52. image: redis:${REDIS_VERSION}
  53. container_name: redis
  54. <<: *common-config
  55. environment:
  56. <<: *common-environment
  57. REDIS_PASSWORD: ${REDIS_PASSWORD}
  58. command: >
  59. redis-server
  60. --requirepass ${REDIS_PASSWORD}
  61. --appendonly yes
  62. --appendfsync everysec
  63. --save 900 1
  64. --save 300 10
  65. --save 60 10000
  66. --maxmemory 512mb
  67. --maxmemory-policy allkeys-lru
  68. --tcp-keepalive 300
  69. --timeout 0
  70. --loglevel notice
  71. volumes:
  72. - ./redis/data:/data
  73. ports:
  74. - "6379:6379"
  75. healthcheck:
  76. test: ["CMD", "redis-cli", "ping"]
  77. interval: 30s
  78. timeout: 10s
  79. retries: 5
  80. # pgadmin:
  81. # image: dpage/pgadmin4:${PGADMIN_VERSION}
  82. # container_name: pgadmin
  83. # <<: *common-config
  84. # environment:
  85. # <<: *common-environment
  86. # PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
  87. # PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
  88. # volumes:
  89. # - ./pgadmin/data:/var/lib/pgadmin
  90. # ports:
  91. # - "8080:80"
  92. # depends_on:
  93. # - postgres
  94. # healthcheck:
  95. # test: ["CMD", "wget", "--spider", "http://localhost:80/login"]
  96. # interval: 30s
  97. # timeout: 10s
  98. # retries: 5
  99. # nginx:
  100. # image: nginx:${NGINX_VERSION}
  101. # container_name: nginx
  102. # <<: *common-config
  103. # environment:
  104. # <<: *common-environment
  105. # volumes:
  106. # - ./nginx/conf.d:/etc/nginx/conf.d
  107. # - ./nginx/html:/usr/share/nginx/html
  108. # ports:
  109. # - "80:80"
  110. # - "443:443"
  111. # healthcheck:
  112. # test: ["CMD", "wget", "--spider", "http://localhost:80"]
  113. # interval: 30s
  114. # timeout: 10s
  115. # retries: 5
  116. nginx-proxy-manager:
  117. image: jc21/nginx-proxy-manager:${NGINX_PROXY_MANAGER_VERSION}
  118. container_name: nginx-proxy-manager
  119. <<: *common-config
  120. environment:
  121. <<: *common-environment
  122. volumes:
  123. - ./nginx-proxy-manager/data:/data
  124. - ./nginx-proxy-manager/letsencrypt:/etc/letsencrypt
  125. ports:
  126. - "80:80"
  127. - "81:81"
  128. - "443:443"
  129. healthcheck:
  130. test: ["CMD", "wget", "--spider", "http://localhost:81"]
  131. interval: 30s
  132. timeout: 10s
  133. retries: 5
  134. gogs:
  135. image: gogs/gogs:${GOGS_VERSION}
  136. container_name: gogs
  137. <<: *common-config
  138. environment:
  139. <<: *common-environment
  140. volumes:
  141. - ./gogs/data:/data
  142. ports:
  143. - "3000:3000"
  144. - "2222:22"
  145. depends_on:
  146. - postgres
  147. healthcheck:
  148. test: ["CMD", "wget", "--spider", "http://localhost:3000"]
  149. interval: 30s
  150. timeout: 10s
  151. retries: 5
  152. networks:
  153. app-tier:
  154. driver: bridge