Browse Source

swagger合并

tags/v4.1.0-dev.9^2
linfengjun 3 weeks ago
parent
commit
59c59460ce
7 changed files with 86 additions and 5 deletions
  1. +50
    -0
      .drone.yml
  2. +17
    -2
      Makefile
  3. +11
    -0
      build/application/api-doc/dockerfile
  4. +2
    -1
      build/basic_environment/kratos-v2/dockerfile
  5. +1
    -1
      server/admin-server/.gitignore
  6. +4
    -0
      server/common/utils/protoc.go
  7. +1
    -1
      server/openai-server/.gitignore

+ 50
- 0
.drone.yml View File

@@ -427,3 +427,53 @@ steps:
from_secret: docker_hub_project
commands:
- make openai-portal_image_push need_latest=FALSE tag=${DRONE_TAG} docker_hub_project=$DOCKER_HUB_PROJECT docker_hub_host=$DOCKER_HUB_HOST docker_hub_userame=$DOCKER_HUB_USERNAME docker_hub_passwd=$DOCKER_HUB_PASSWD

---
kind: pipeline
name: api-doc
type: kubernetes
platform:
os: linux
arch: amd64
trigger:
event:
- tag
volumes:
- name: docker
host:
path: /var/run/
steps:
# - name: 代码检查
# image: golangci/golangci-lint:v1.40.1
# environment:
# GO111MODULE: on
# GOPROXY: https://goproxy.cn,direct
# commands:
# - make admin-server_lint

- name: 构建镜像
image: swr.cn-south-1.myhuaweicloud.com/openioctopus/docker:20.10.6-make
volumes:
- name: docker
path: /var/run/
commands:
- make api-doc_image tag=${DRONE_TAG}

- name: 镜像推送
image: swr.cn-south-1.myhuaweicloud.com/openioctopus/docker:20.10.6-make
volumes:
- name: docker
path: /var/run/
environment:
DOCKER_HUB_HOST:
from_secret: docker_hub_host
DOCKER_HUB_USERNAME:
from_secret: docker_hub_userame
DOCKER_HUB_PASSWD:
from_secret: docker_hub_passwd
DOCKER_HUB_PROJECT:
from_secret: docker_hub_project
commands:
- make api-doc_image_push need_latest=FALSE tag=${DRONE_TAG} docker_hub_project=$DOCKER_HUB_PROJECT docker_hub_host=$DOCKER_HUB_HOST docker_hub_userame=$DOCKER_HUB_USERNAME docker_hub_passwd=$DOCKER_HUB_PASSWD

---

+ 17
- 2
Makefile View File

@@ -73,6 +73,8 @@ vc-controller_build: init
scheduler_build: init
cd ./server/taskset && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./main/scheduler

api-doc_build: init
cd ./server && go generate
# 运行
all_run: server_run

@@ -165,7 +167,7 @@ taskset_lint: lint_init
cd ./server/taskset && golangci-lint run ./...

# 构建镜像
images: base-server_image admin-server_image openai-server_image taskset_image admin-portal_image openai-portal_image
images: base-server_image admin-server_image openai-server_image taskset_image admin-portal_image openai-portal_image api-doc_image

base-server_image:
docker build --no-cache -t base-server:${RELEASE_VER} -f ./build/application/base-server/dockerfile .
@@ -193,8 +195,11 @@ admin-portal_image:
openai-portal_image:
docker build --no-cache -t openai-portal:${RELEASE_VER} -f ./build/application/openai-portal/dockerfile .

api-doc_image:
docker build --no-cache -t api-doc:${RELEASE_VER} -f ./build/application/api-doc/dockerfile .

# 镜像推送
images_push: base-server_image_push admin-server_image_push openai-server_image_push taskset_image_push admin-portal_image_push openai-portal_image_push
images_push: base-server_image_push admin-server_image_push openai-server_image_push taskset_image_push admin-portal_image_push openai-portal_image_push api-doc_image_push

image_push_init:
(echo ${DOCKER_HUB_PASSWD} | docker login ${DOCKER_HUB_HOST} -u ${DOCKER_HUB_USERNAME} --password-stdin) 1>/dev/null 2>&1
@@ -290,6 +295,16 @@ ifeq (${NEED_LATEST}, TRUE)
endif
endif

api-doc_image_push: image_push_init
docker tag api-doc:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/api-doc:${RELEASE_VER}
docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/api-doc:${RELEASE_VER}

ifneq (${RELEASE_VER}, latest)
ifeq (${NEED_LATEST}, TRUE)
docker tag api-doc:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/api-doc:latest
docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/api-doc:latest
endif
endif

# helm chart
charts: charts_build charts_push


+ 11
- 0
build/application/api-doc/dockerfile View File

@@ -0,0 +1,11 @@
from swr.cn-south-1.myhuaweicloud.com/openioctopus/kratos:v2 as builder
WORKDIR /app
COPY ./ ./

RUN make api-doc_build

FROM swaggerapi/swagger-ui
WORKDIR /app
COPY --from=builder /app/server/admin-server/api/v1/swagger.json /usr/share/nginx/html/admin-server.swagger.json
COPY --from=builder /app/server/openai-server/api/v1/swagger.json /usr/share/nginx/html/openai-server.swagger.json
ENV URLS "[{url:\"/admin-server.swagger.json\",name:\"admin\"},{url:\"/openai-server.swagger.json\",name:\"openai\"}]"

+ 2
- 1
build/basic_environment/kratos-v2/dockerfile View File

@@ -14,4 +14,5 @@ RUN go get -u google.golang.org/protobuf/cmd/protoc-gen-go@v1.26.0 \
&& go get -u github.com/envoyproxy/protoc-gen-validate@v0.5.1 \
&& go get -u github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@46acad3 \
&& go get -u github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@46acad3 \
&& go get -u github.com/go-kratos/kratos/v2@v2.0.0-beta3
&& go get -u github.com/go-kratos/kratos/v2@v2.0.0-beta3 \
&& go get -u github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.6.0

+ 1
- 1
server/admin-server/.gitignore View File

@@ -38,4 +38,4 @@ bin/
# pb
*.pb.go
*.pb.validate.go
*.swagger.json
*swagger.json

+ 4
- 0
server/common/utils/protoc.go View File

@@ -125,6 +125,10 @@ func Generate() error {
return err
}

err = GenSwagger()
if err != nil {
return err
}
return nil
}



+ 1
- 1
server/openai-server/.gitignore View File

@@ -38,4 +38,4 @@ bin/
# pb
*.pb.go
*.pb.validate.go
*.swagger.json
*swagger.json

Loading…
Cancel
Save