animeic 2 years ago
commit
e091b4fe8d
7 changed files with 190 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 36 0
      config-service.yaml
  3. 78 0
      docker-compose.yaml
  4. 56 0
      nginx/conf.d/default.conf
  5. 1 0
      nginx/www/index.html
  6. 14 0
      readme.md
  7. 4 0
      start.sh

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+local*

+ 36 - 0
config-service.yaml

@@ -0,0 +1,36 @@
+log:
+  fileName: comm-bus.log
+  level: 1
+  serviceName: bus
+  
+configer:
+  -
+    name: mongo
+    value: mongodb://root:alpha@comm-mongo-alpha:27017/comm?authSource=admin
+    devValue: mongodb://root:alpha@124.71.139.24:37017/comm?authSource=admin
+  # -
+  #   name: user-mongo
+  #   value: mongodb://root:alpha@comm-mongo-alpha:27017/usercenter?authSource=admin
+  #   devValue: mongodb://root:alpha@124.71.139.24:37017/usercenter?authSource=admin
+  -
+    name: redis
+    value: comm-redis:6379#0#default#packcomm
+
+# adapter:
+#   -
+#     busName:
+#       service2
+#     nats:
+#       nats://pack2-nats-1:4222
+#     apis:
+#       - service2.licence.check
+#     streams:
+#       - service2-vip-pay#service2.pay.succ
+startLocalNats: true
+startNatsShellParams: "-p 4222 -m 8222 -js"
+startNatsPort: 4222
+
+nats:
+  url: nats://comm-bus:4222
+  maxReconnect: 10000
+  reconnDelaySecond: 5

+ 78 - 0
docker-compose.yaml

@@ -0,0 +1,78 @@
+version: '3.8'
+
+# 网络
+networks:
+  default:
+    external:
+      name: default-network
+
+services:
+  #nginx反向代理
+  nginx:
+    image: "registry.cn-chengdu.aliyuncs.com/infish/pack-comm-nginx:1.23.1"
+    restart: always
+    ports:
+      - 18080:80
+    volumes:
+      - ./nginx/conf.d:/etc/nginx/conf.d
+      - ./nginx/www:/usr/share/nginx/html
+
+  #bus消息中间件
+  comm-bus:
+    restart: always
+    image: registry.cn-chengdu.aliyuncs.com/infish/pack-comm-bus:v1.0.0
+    volumes:
+      - ./config-service.yaml:/root/bus/app.yaml
+
+    depends_on:
+      - comm-mongo-alpha
+      - comm-redis    
+    ports:
+      - 14221:4222
+
+  # # nats服务监控采集 7777
+  # nats-exporter:
+  #   restart: always
+  #   image: natsio/prometheus-nats-exporter:latest
+  #   command: "-varz http://comm-bus:8222"
+  #   depends_on:
+  #     - comm-bus
+
+  #redis缓存
+  comm-redis:
+    image: "redis:alpine"
+    restart: always
+    command:
+      --requirepass "packcomm" #这一行是设置密码
+    privileged: true
+
+  #mongo -alpha数据库
+  comm-mongo-alpha:
+    image: mongo:4.4.1
+    restart: always
+    environment:
+      MONGO_INITDB_ROOT_USERNAME: root
+      MONGO_INITDB_ROOT_PASSWORD: alpha
+    volumes:
+      - ~/data/packs-comm/mongo-alpha/db:/data/db
+      - ~/data/packs-comm/mongo-alpha/log:/var/log/mongodb
+    ports: 
+      - 37017:27017
+
+  # 支付服务 8888
+  comm-pay:
+    image: registry.cn-chengdu.aliyuncs.com/infish/pack-comm-pay:v1.0.0
+    restart: always
+    depends_on:
+      - comm-bus
+    environment: 
+       NATS: nats://comm-bus:4222
+
+  # 用户中心 8908
+  # comm-usercenter:
+  #   image: registry.cn-chengdu.aliyuncs.com/infish/pack-comm-usercenter:v1.0.0
+  #   restart: always
+  #   depends_on:
+  #     - comm-bus
+  #   environment: 
+  #     NATS: nats://comm-bus:4222

+ 56 - 0
nginx/conf.d/default.conf

@@ -0,0 +1,56 @@
+server {
+    listen       80;
+    listen  [::]:80;
+    server_name  localhost;
+    #access_log  /var/log/nginx/host.access.log  main;
+    location / {
+        root   /usr/share/nginx/html;
+        index  index.html index.htm;
+    }
+    #error_page  404              /404.html;
+
+    # redirect server error pages to the static page /50x.html
+    #
+    error_page   500 502 503 504  /50x.html;
+    location = /50x.html {
+        root   /usr/share/nginx/html;
+    }
+
+    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+    #
+    #location ~ \.php$ {
+    #    proxy_pass   http://127.0.0.1;
+    #}
+
+    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+    #
+    #location ~ \.php$ {
+    #    root           html;
+    #    fastcgi_pass   127.0.0.1:9000;
+    #    fastcgi_index  index.php;
+    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
+    #    include        fastcgi_params;
+    #}
+
+    # deny access to .htaccess files, if Apache's document root
+    # concurs with nginx's one
+    #
+    #location ~ /\.ht {
+    #    deny  all;
+    #}
+
+    # 支付接口
+    location /pay/ {
+       proxy_pass  http://comm-pay:8888/pay/;
+    }   
+
+    # 用户接口
+    # location /usercenter/ {
+    #    proxy_pass  http://comm-usercenter:8908/usercenter/;
+    # }
+
+    #nats-exporter
+    # location /natsexporter/ {
+    #    proxy_pass  http://nats-exporter:7777/;
+    # }
+}

+ 1 - 0
nginx/www/index.html

@@ -0,0 +1 @@
+hello world~!!!

+ 14 - 0
readme.md

@@ -0,0 +1,14 @@
+# 包含的微服务说明
+1 pay 模块 registry.cn-chengdu.aliyuncs.com/infish/sku3dpaytest:latest
+    environment:
+      REDIS: redis:6379/0
+      NATS: nats://192.168.0.162:24222
+
+    ports:
+      - 18888:8888
+
+## 流程
+
+1. 构建每个服务的镜像
+2. 配置到对应service的image下
+3. docker compose up

+ 4 - 0
start.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+
+docker-compose up -d --remove-orphans
+docker-compose ps