Browse Source

初步启动脚本、添加nginx配置

lsl 2 years ago
parent
commit
292b2ede9a
2 changed files with 114 additions and 51 deletions
  1. 70 51
      docker-compose.yaml
  2. 44 0
      nginx/conf.d/app.conf

+ 70 - 51
docker-compose.yaml

@@ -1,61 +1,80 @@
-version: '3'
-services:
-  nginx:
-   container_name: app-nginx
-   image: nginx:1.13
-   restart: always
-   ports:
-   - 11800:80
-   volumes:
-   - ./nginx/conf.d:/etc/nginx/conf.d
-   depends_on:
-   - app
-
-  ali1:
-    restart: always
-    container_name: ali_service_1
-    build: ali
-    expose:
-      - "8095"
-
-  # ali2:
-  #   restart: always
-  #   container_name: ali_service_2
-  #   build: ali
-  #   expose:
-  #     - "8096"
-
-  mt1:
+version: '5'
+services:
+  nginx:
+   container_name: app-nginx
+   image: nginx:1.13
+   restart: always
+   ports:
+   - 11800:80
+   volumes:
+   - ./nginx/conf.d:/etc/nginx/conf.d
+   depends_on:
+   - ali-biz1
+   - mt-manager
+   - consumer-manager
+   - web-manager
+
+  ali-biz1:
+    restart: always
+    build: ./mt-backend/ali-manager/
+    working_dir: /app
+    volumes:
+      - ./app:/app
+    expose:
+      - "8095"
+    environment:
+     - "SPRING_PROFILES_ACTIVE=prod"
+
+  # ali2:
+  #   restart: always
+  #   container_name: ali_service_2
+  #   build: ali
+  #   expose:
+  #     - "8096"
+
+
  mt-manager:
     restart: always
     restart: always
-    container_name: mt_service_2
-    build: mt
+    build: ./mt-backend/mt-manager/
+    working_dir: /app
+    volumes:
+      - ./app:/app
     expose:
     expose:
       - "8090"
       - "8090"
+    environment:
+     - "SPRING_PROFILES_ACTIVE=prod"
 
 
-  # mt2:
-  #   restart: always
-  #   container_name: mt_service_2
-  #   build: mt
-  #   expose:
-  #     - "8090"
-      
-  consumer-basic:
-    restart: always
-    container_name: consumer-basic
-    build: consumer-basic
-    expose:
-      - "9000"
-      
-  consumer-store:
+  # mt2:
+  #   restart: always
+  #   container_name: mt_service_2
+  #   build: mt
+  #   expose:
+  #     - "8090"
+      
+#  consumer-basic:
+#    restart: always
+#    container_name: consumer-basic
+#    build: consumer-basic
+#    expose:
+#      - "9000"
+
+  consumer-manager:
     restart: always
     restart: always
-    container_name: consumer-store
-    build: consumer-store
+    build: ./mt-backend/consumer-manager/
+    working_dir: /app
+    volumes:
+      - ./app:/app
     expose:
     expose:
       - "9005"
       - "9005"
-      
+    environment:
+     - "SPRING_PROFILES_ACTIVE=prod"
+     
   web-manager:
   web-manager:
     restart: always
     restart: always
-    container_name: web-manager
-    build: web-manager
+    build: ./mt-backend/web-manager/
+    working_dir: /app
+    volumes:
+      - ./app:/app
     expose:
     expose:
-      - "8080"
+      - "8080"
+    environment:
+     - "SPRING_PROFILES_ACTIVE=prod" 

+ 44 - 0
nginx/conf.d/app.conf

@@ -0,0 +1,44 @@
+server {
+    listen 80;
+    charset utf-8;
+    access_log off;
+
+    location /ali {
+        proxy_pass http://ali-biz1:8095;
+        proxy_set_header Host $host:$server_port;
+        proxy_set_header X-Forwarded-Host $server_name;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    }
+
+    location /mt {
+        proxy_pass http://mt-manager:8090;
+        proxy_set_header Host $host:$server_port;
+        proxy_set_header X-Forwarded-Host $server_name;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    }
+
+    location /consumer {
+        proxy_pass http://consumer-manager:9005;
+        proxy_set_header Host $host:$server_port;
+        proxy_set_header X-Forwarded-Host $server_name;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    }
+
+    location /web {
+        proxy_pass http://web-manager:8080;
+        proxy_set_header Host $host:$server_port;
+        proxy_set_header X-Forwarded-Host $server_name;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    }
+    
+    location /static {
+        access_log   off;
+        expires      30d;
+
+        alias /app/static;
+    }
+}