先贴官方地址,我的做法差不多 https://github.com/goharbor/harbor/blob/master/docs/configure_swagger.md
1.下载对应资源
wget https://raw.githubusercontent.com/goharbor/harbor/master/docs/prepare-swagger.sh https://raw.githubusercontent.com/goharbor/harbor/master/docs/swagger.yaml
2.编辑prepare-swagger.sh
vi prepare-swagger.sh
SCHEME=<HARBOR_SERVER_SCHEME>、SERVER_IP=<HARBOR_SERVER_DOMAIN>
3.修改文件mode
chmod +x prepare-swagger.sh
4.执行脚本
./prepare-swagger.sh
5.将上级目录中src中的对应资源cp 到harbor-ui中,重启容器(官方这一步是在docker-compose.yaml中的harbor-ui中挂载进去的)
docker cp ../src/ui/static/vendors/swagger-ui-2.1.4/dist harbor-ui:/harbor/static/vendors/swagger docker cp ../src/ui/static/resources/yaml/swagger.yaml harbor-ui:/harbor/static/resources/yaml/swagger.yaml
对应资源与对应容器目录为
../src/ui/static/vendors/swagger-ui-2.1.4/dist:/harbor/static/vendors/swagger
../src/ui/static/resources/yaml/swagger.yaml:/harbor/static/resources/yaml/swagger.yaml
6.swagger主页
http://<HARBOR_SERVER>/static/vendors/swagger/index.html
7.调试可以新开tag登录harbor。这样共享session,swagger就得到授权可以调试了
8.主页404,说明cp路径不对。进入harbor-ui 检查cp进去的路径