diff --git a/.drone.yml b/.drone.yml index 225ee0c..35693b3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,3 +1,13 @@ +# Code generated by wujian-develop_tool. DO NOT EDIT. + kind: pipeline type: monorepo -name: backend +name: monorepo +api: + - nameSpace: zeus + name: lark + aliasName: 飞书 + root: app/zeus/api/lark + type: golang + port: "8080" +service: [] diff --git a/app/service/.keep b/app/service/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/app/zeus/api/lark/Dockerfile b/app/zeus/api/lark/Dockerfile new file mode 100755 index 0000000..245c930 --- /dev/null +++ b/app/zeus/api/lark/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:1.17 as builder +ENV GO111MODULE on +ENV GOPROXY https://goproxy.io,direct +WORKDIR /go/cache +ADD go.mod . +ADD go.sum . +RUN go mod download -x +WORKDIR /go/src +ADD . . +RUN go mod tidy +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o api_lark ./app/zeus/api/lark + +FROM reg.icechen.cn/alpine as lark +WORKDIR /go/src +COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=builder /go/src/api_lark ./ +ENV TZ=Asia/Shanghai +RUN chmod +x ./api_lark +EXPOSE 8080 +CMD ["./api_lark"] \ No newline at end of file diff --git a/app/zeus/api/lark/deploy/.helmignore b/app/zeus/api/lark/deploy/.helmignore new file mode 100755 index 0000000..0e8a0eb --- /dev/null +++ b/app/zeus/api/lark/deploy/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/app/zeus/api/lark/deploy/Chart.yaml b/app/zeus/api/lark/deploy/Chart.yaml new file mode 100755 index 0000000..30cbf6f --- /dev/null +++ b/app/zeus/api/lark/deploy/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: lark +description: 飞书 + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.1 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.0.1" diff --git a/app/zeus/api/lark/deploy/templates/NOTES.txt b/app/zeus/api/lark/deploy/templates/NOTES.txt new file mode 100755 index 0000000..3041ade --- /dev/null +++ b/app/zeus/api/lark/deploy/templates/NOTES.txt @@ -0,0 +1 @@ +notes \ No newline at end of file diff --git a/app/api/.keep b/app/zeus/api/lark/deploy/templates/_helpers.tpl old mode 100644 new mode 100755 similarity index 100% rename from app/api/.keep rename to app/zeus/api/lark/deploy/templates/_helpers.tpl diff --git a/app/zeus/api/lark/deploy/templates/application.yaml b/app/zeus/api/lark/deploy/templates/application.yaml new file mode 100755 index 0000000..ec8cc30 --- /dev/null +++ b/app/zeus/api/lark/deploy/templates/application.yaml @@ -0,0 +1,20 @@ +apiVersion: app.k8s.io/v1beta1 +kind: Application +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.nameSpace }} + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + annotations: + servicemesh.kubesphere.io/enabled: 'true' +spec: + selector: + matchLabels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + addOwnerRef: true \ No newline at end of file diff --git a/app/zeus/api/lark/deploy/templates/deployment.yaml b/app/zeus/api/lark/deploy/templates/deployment.yaml new file mode 100755 index 0000000..6f357bb --- /dev/null +++ b/app/zeus/api/lark/deploy/templates/deployment.yaml @@ -0,0 +1,76 @@ +kind: Deployment +apiVersion: apps/v1 +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.nameSpace }} + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} + annotations: + kubesphere.io/alias-name: {{ .Values.aliasName }} + kubesphere.io/creator: drone + meta.helm.sh/release-name: {{ .Release.Name }} + meta.helm.sh/release-namespace: {{ .Values.nameSpace }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + volumes: + - name: host-time + hostPath: + path: /etc/localtime + type: '' + containers: + - name: {{ .Release.Name }} + image: {{ .Values.image }}:{{ .Values.imageTag }} + ports: + - containerPort: {{ .Values.port }} + protocol: TCP + env: + - name: endpoints + value: 'etcd:2379' + resources: + limits: + cpu: 200m + memory: 1000Mi + requests: + cpu: 10m + memory: 200Mi + volumeMounts: + - name: host-time + readOnly: true + mountPath: /etc/localtime + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + imagePullPolicy: IfNotPresent + restartPolicy: Always + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + securityContext: {} + imagePullSecrets: + - name: registry-secret + schedulerName: default-scheduler + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 25% + maxSurge: 25% + revisionHistoryLimit: 10 + progressDeadlineSeconds: 600 \ No newline at end of file diff --git a/app/zeus/api/lark/deploy/templates/ingress.yaml b/app/zeus/api/lark/deploy/templates/ingress.yaml new file mode 100755 index 0000000..cd01aa7 --- /dev/null +++ b/app/zeus/api/lark/deploy/templates/ingress.yaml @@ -0,0 +1,30 @@ +{{ if and .Values.host .Values.path }} +kind: Ingress +apiVersion: networking.k8s.io/v1 +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.nameSpace }} + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} + annotations: + kubesphere.io/creator: drone + nginx.ingress.kubernetes.io/enable-cors: 'true' + nginx.ingress.kubernetes.io/rewrite-target: /$1 + nginx.ingress.kubernetes.io/use-regex: 'true' +spec: + rules: + - host: {{ .Values.host }} + http: + paths: + - path: {{ .Values.path }} + pathType: ImplementationSpecific + backend: + service: + name: {{ .Release.Name }} + port: + number: 80 + {{ end }} \ No newline at end of file diff --git a/app/zeus/api/lark/deploy/templates/service.yaml b/app/zeus/api/lark/deploy/templates/service.yaml new file mode 100755 index 0000000..4cbc43c --- /dev/null +++ b/app/zeus/api/lark/deploy/templates/service.yaml @@ -0,0 +1,26 @@ +kind: Service +apiVersion: v1 +metadata: + name: {{ .Release.Name }} + namespace: {{ .Values.nameSpace }} + annotations: + kubesphere.io/creator: drone + labels: + app: {{ .Release.Name }} + app.kubernetes.io/version: v1 + app.kubernetes.io/name: {{ .Release.Name }} + version: v1 + app.kubernetes.io/instance: {{ .Release.Name }} +spec: + ports: + - name: http-{{ .Release.Name }} + protocol: TCP + port: 80 + targetPort: {{ .Values.port }} + selector: + app: {{ .Release.Name }} + type: ClusterIP + sessionAffinity: None + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack \ No newline at end of file diff --git a/app/zeus/api/lark/deploy/values.yaml b/app/zeus/api/lark/deploy/values.yaml new file mode 100755 index 0000000..3d581af --- /dev/null +++ b/app/zeus/api/lark/deploy/values.yaml @@ -0,0 +1,7 @@ +nameSpace: zeus +aliasName: 飞书 +image: reg.icechen.cn/zeus/api-lark +imageTag: latest +port: 8080 +host: api.seamlesser.com +path: /zeus/lark/?(.*) \ No newline at end of file diff --git a/app/zeus/api/lark/main.go b/app/zeus/api/lark/main.go new file mode 100755 index 0000000..6a21d34 --- /dev/null +++ b/app/zeus/api/lark/main.go @@ -0,0 +1,11 @@ +package main + +import "github.com/gofiber/fiber/v2" + +func main() { + router := fiber.New() + router.Get("/user", func(ctx *fiber.Ctx) error { + return ctx.SendString("user") + }) + router.Listen(":8080") +} diff --git a/go.mod b/go.mod index 54962dd..7ca6d38 100644 --- a/go.mod +++ b/go.mod @@ -2,3 +2,13 @@ module git.icechen.cn/monorepo/backend go 1.17 +require github.com/gofiber/fiber/v2 v2.24.0 + +require ( + github.com/andybalholm/brotli v1.0.2 // indirect + github.com/klauspost/compress v1.13.4 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.31.0 // indirect + github.com/valyala/tcplisten v1.0.0 // indirect + golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..931c15b --- /dev/null +++ b/go.sum @@ -0,0 +1,24 @@ +github.com/andybalholm/brotli v1.0.2 h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E= +github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/gofiber/fiber/v2 v2.24.0 h1:18rpLoQMJBVlLtX/PwgHj3hIxPSeWfN1YeDJ2lEnzjU= +github.com/gofiber/fiber/v2 v2.24.0/go.mod h1:MR1usVH3JHYRyQwMe2eZXRSZHRX38fkV+A7CPB+DlDQ= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/klauspost/compress v1.13.4 h1:0zhec2I8zGnjWcKyLl6i3gPqKANCCn5e9xmviEEeX6s= +github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.31.0 h1:lrauRLII19afgCs2fnWRJ4M5IkV0lo2FqA61uGkNBfE= +github.com/valyala/fasthttp v1.31.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus= +github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=