瀏覽代碼

配置docker

zrufo 4 年之前
父節點
當前提交
251902445a
共有 3 個文件被更改,包括 149 次插入0 次删除
  1. 26 0
      docker-compose.yaml
  2. 61 0
      envoy.yaml
  3. 62 0
      update.ps1

+ 26 - 0
docker-compose.yaml

@@ -0,0 +1,26 @@
+version: '3'
+services:
+  server:
+    container_name: sportfitness_base
+    volumes:
+      - /etc/localtime:/etc/localtime
+    image: docker.beswell.com:5050/sportfitness/base
+    ports:
+      - "20013:19090"
+    restart: always
+    environment:
+      CONSUL_ADDR: 172.17.0.1:8500
+
+  envoy:
+    container_name: sportfitness_base_envory
+    image: envoyproxy/envoy
+    network_mode: "host"
+    environment:
+      - SERVICE_20011_NAME=sportfitness/base/web_api
+      - SERVICE_20012_NAME=sportfitness/base/envory_ui
+    ports:
+      - "20014:20011"
+      - "20015:20012"
+    restart: always
+    volumes:
+      - ./envoy.yaml:/etc/envoy/envoy.yaml

+ 61 - 0
envoy.yaml

@@ -0,0 +1,61 @@
+admin:
+  access_log_path: /tmp/admin_access.log
+  address:
+    socket_address: { address: 0.0.0.0, port_value: 20012 }
+
+static_resources:
+  listeners:
+    - name: listener_0
+      address:
+        socket_address: { address: 0.0.0.0, port_value: 20011 }
+      filter_chains:
+        - filters:
+            - name: envoy.filters.network.http_connection_manager
+              typed_config:
+                "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
+                codec_type: auto
+                stat_prefix: ingress_http
+                use_remote_address: true
+                route_config:
+                  name: local_route
+                  request_headers_to_remove: "X-Forwarded-For"
+                  request_headers_to_add:
+                    header:
+                      key: "X-Forwarded-For"
+                      value: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"
+
+
+                  virtual_hosts:
+                    - name: local_service
+                      domains: ["*"]
+                      routes:
+                        - match: { prefix: "/" }
+                          route:
+                            cluster: echo_service
+                            timeout: 0s
+                      cors:
+                        allow_origin_string_match:
+                          - prefix: "*"
+                        allow_methods: GET, PUT, DELETE, POST, OPTIONS
+                        allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout,token,authorization
+                        max_age: "1728000"
+                        expose_headers: custom-header-1,grpc-status,grpc-message
+                http_filters:
+                  - name: envoy.filters.http.grpc_web
+                  - name: envoy.filters.http.cors
+                  - name: envoy.filters.http.router
+  clusters:
+    - name: echo_service
+      connect_timeout: 0.25s
+      type: logical_dns
+      http2_protocol_options: {}
+      lb_policy: round_robin
+      load_assignment:
+        cluster_name: cluster_0
+        endpoints:
+          - lb_endpoints:
+              - endpoint:
+                  address:
+                    socket_address:
+                      address: 0.0.0.0
+                      port_value: 20013

+ 62 - 0
update.ps1

@@ -0,0 +1,62 @@
+param(
+    [switch]$u
+)
+$beginPWD = $PWD
+Write-Output $addHosts
+$dockerImage ="docker.beswell.com:5050/sportfitness/base"
+
+if ($u)
+{
+    $cmd = "docker pull ${dockerImage}:latest"
+    Write-Output "更新稳定版"
+    Invoke-Expression $cmd
+}
+Set-Location $PSScriptRoot
+
+
+#try {
+#    docker stop bsw_im
+#}
+#catch {
+#}
+#try {
+#    docker rm bsw_im
+#}
+#catch {
+#}
+
+if ($IsWindows) {
+    $configPath = $PSScriptRoot
+    $consulAddr = "host.docker.internal:8500"
+    $hostsPath = "C:\WINDOWS\system32\drivers\etc\hosts"
+    $timeZone =" "
+}
+if ($IsLinux){
+    $configPath = "/etc/bsw/signaldig2"
+    $consulAddr = "172.17.0.1:8500"
+    $hostsPath = "/etc/hosts"
+    $timeZone = " -v /etc/localtime:/etc/localtime "
+}
+
+$hosts = Get-Content $hostsPath | Where-Object { $true -ne [string]::IsNullOrWhiteSpace($_) }
+$addHosts = ""
+foreach ($item in $hosts) {
+
+    if (!($item -match ".*#.*")) {
+        $array = $item.Split("`t", [StringSplitOptions]::RemoveEmptyEntries)
+        $ip = $array[0]
+        $hostArray = $array[1..$array.Length]
+        
+        foreach ($h in $hostArray){
+            $addHosts = $addHosts + " --add-host ${h}:$ip "
+        }
+    }
+}
+
+
+docker-compose up -d
+
+Set-Location $beginPWD
+#$cmd = "docker run -d -P --name bsw_im $addHosts $timeZone -e CONSUL_ADDR=$consulAddr --restart=always ${dockerImage}:latest"
+#Write-Output "exec cmd: $cmd"
+#Invoke-Expression $cmd