本文共 4095 字,大约阅读时间需要 13 分钟。
由于要在zipkin的界面基础上进行修改,所以需要单独打包zipkin-ui并以docker形式跑起来(zipkin后台一直运行着)。一个学长曾经做过,记录如下,亲测可用:
Maven打包zipkin:parent(root) -> package
把打好的zipkin-ui.jar包放到文件夹zipkin-ui中,里面还要放入三个文件:
user nginx nginx;worker_processes 2;error_log /dev/stderr warn;pid /var/run/nginx.pid;daemon off;events { worker_connections 1024;}http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /dev/stdout main; sendfile on; #tcp_nopush on; keepalive_timeout 65; gzip on; gzip_types application/javascript application/json text/css; server_tokens off; types { application/font-woff2 woff2; } server { listen 9091; root /var/www/html; index index.html; # Make site accessible from http://set-ip-address.xip.io server_name localhost; charset utf-8; # redirect root as UI is hosted under /zipkin location / { return 302 /zipkin/; } # the entrypoint of the app will expire every day. # this includes links to js assets with random names. location /zipkin/index.html { expires 1d; } location /zipkin { try_files $uri /zipkin/index.html = 404; } # accept UI config from the server location /zipkin/config.json { expires 10m; proxy_pass ${ZIPKIN_BASE_URL}; } # the UI looks for the api under the same relative path location /zipkin/api { expires off; proxy_pass ${ZIPKIN_BASE_URL}; } # due to minification, the js assets will change names. # this makes them safe to cache longer location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { expires 1y; add_header Cache-Control "public"; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { access_log off; log_not_found off; } # Deny .htaccess file access location ~ /\.ht { deny all; } }}
#!/bin/shenvsubst '\$ZIPKIN_BASE_URL' < /etc/nginx/conf.d/zipkin.conf.template > /etc/nginx/nginx.confexec nginx
# pins on 1.11 as it is built against Alpine 3.4 which doesn't die with SSL certificate problemFROM nginx:1.11-alpineENV ZIPKIN_VERSION 2.10.1#!!!!!!change to your zipkin backend ip:port!!!!!!!!!!ENV ZIPKIN_BASE_URL=http://xxxxx:xxx#!!!!!!change to your zipkin-ui.jar name!!!!!!!!!!!COPY zipkin-ui-2.10.1-SNAPSHOT.jar zipkin-ui-2.10.1-SNAPSHOT.jar# Setup servicesADD nginx.conf /etc/nginx/conf.d/zipkin.conf.templateADD run.sh /usr/local/bin/nginx.shRUN apk add --update --no-cache nginx curl && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* && \ mkdir /var/www/html && \ unzip zipkin-ui-2.10.1-SNAPSHOT.jar 'zipkin-ui/*' -d /var/www/html && \ mv /var/www/html/zipkin-ui /var/www/html/zipkin && \ rm -rf zipkin-ui-2.10.1-SNAPSHOT.jar && \ chmod +x /usr/local/bin/nginx.shEXPOSE 9091CMD ["/usr/local/bin/nginx.sh"]
#【docker build -t (镜像名) -f (Dockerfile文件的路径) (上下文路径)】#(最后的点号不要忘记)docker build -t zipkin-ui -f Dockerfile .#跑一下试试docker run -p 9091:9091 zipkin-ui#打tag、push到docker hubdocker tag zipkin-ui xxx/zipkin-uidocker push xxx/zipkin-ui
# This file uses the version 2 docker-compose file format, described here:# https://docs.docker.com/compose/compose-file/#version-2## It extends the default configuration from docker-compose.yml, hosting the# ui on port 80 using NGINXversion: '2'services: zipkin-ui: build: zipkin-ui #change to your image uri image: xxxx/zipkin-ui container_name: zipkin-ui environment: # Change this if connecting to a different zipkin server - ZIPKIN_BASE_URL=http://xxxxx:xxx ports: - 9091:9091
转载地址:http://tokvb.baihongyu.com/