diff --git a/db/postgresql/docker-compose.yml b/db/postgresql/docker-compose.yml new file mode 100644 index 0000000..8f5f382 --- /dev/null +++ b/db/postgresql/docker-compose.yml @@ -0,0 +1,84 @@ +version: "3.9" +services: + reverse-proxy: + image: traefik:v2.5 + restart: always + labels: + - "traefik.enable=true" + - "traefik.http.routers.traefik-dashboard.entrypoints=web" + - "traefik.http.routers.traefik-dashboard.service=api@internal" + - "traefik.http.routers.traefik-dashboard.rule=Host(`localhost`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))" + - "traefik.http.middlewares.traefik-dashboard.compress=true" + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + ports: + - "80:80" + - "8082:8082" + - "5432:5432" + networks: + - traefik + command: + - "--global.sendanonymoususage=false" + - "--global.checknewversion=false" + # EntryPoints + - "--entrypoints.web.address=:80" + - "--entrypoints.db-pg.address=:5432" + - "--entryPoints.metrics.address=:8082" + # Enable dashboard + - "--api.dashboard=true" + - "--api.insecure=true" + - "--ping" + # Provider + - "--providers.docker.network=${TRAEFIK_NETWORK}" + - "--providers.docker.watch=true" + - "--providers.docker.exposedByDefault=false" + # Metrics + - "--metrics.prometheus.entryPoint=metrics" + - "--metrics.prometheus.buckets=0.100000, 0.300000, 1.200000, 5.000000" + - "--metrics.prometheus.addrouterslabels=true" + - "--metrics.prometheus.addServicesLabels=true" + # Tracing + - "--tracing=true" + - "--tracing.serviceName=traefik" + - "--tracing.spanNameLimit=150" + # Logging + - "--log.filePath=/var/log/traefik.log" + - "--log.format=json" + - "--log.level=INFO" + - "--accessLog.filepath=/var/log/access.log" + - "--accessLog.format=json" + - "--accessLog.bufferingsize=100" + + postgres: + image: postgres:14.1-alpine + restart: always + environment: + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + labels: + - "traefik.enable=true" + - "traefik.tcp.routers.postgres.entrypoints=db-pg" + - "traefik.tcp.routers.postgres.rule=HostSNI(`*`)" + - "traefik.tcp.services.postgres.loadbalancer.server.port=5432" + networks: + - traefik + + pgweb: + image: sosedoff/pgweb + environment: + - "TZ=Asia/Shanghai" + - "SESSIONS=1" + labels: + - "traefik.enable=true" + - "traefik.http.routers.pgweb.rule=Host(`pgweb.localhost`)" + - "traefik.http.routers.pgweb.entrypoints=web" + - "traefik.http.routers.pgweb.middlewares=pgweb" + - "traefik.http.middlewares.pgweb.compress=true" + - "traefik.http.middlewares.pgweb.compress.excludedcontenttypes=text/event-stream" + - "traefik.http.services.pgweb.loadbalancer.server.port=8081" + networks: + - traefik + +networks: + traefik: + name: ${TRAEFIK_NETWORK} + external: true \ No newline at end of file