dengbiao vor 1 Woche
Ursprung
Commit
3e5501f12e
5 geänderte Dateien mit 72 neuen und 33 gelöschten Zeilen
  1. +8
    -6
      Dockerfile
  2. +7
    -7
      go.mod
  3. +20
    -20
      k8s/container.yaml
  4. +17
    -0
      k8s/ingress.yaml
  5. +20
    -0
      k8s/ingress_prd.yaml

+ 8
- 6
Dockerfile Datei anzeigen

@@ -13,23 +13,25 @@ WORKDIR /go/release
# 把全部文件添加到/go/release目录
ADD . .

# 编译:把main.go编译成可执行的二进制文件,命名为zyos
RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o zyos main.go
# 编译:把main.go编译成可执行的二进制文件,命名为egg
RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o egg main.go

FROM ubuntu:xenial as prod
LABEL maintainer="wuhanqin"
LABEL maintainer="dengbiao"
ENV TZ="Asia/Shanghai"

COPY static/html static/html
COPY docs docs

# 时区纠正
RUN rm -f /etc/localtime \
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
# 在build阶段复制可执行的go二进制文件app
COPY --from=build /go/release/zyos ./zyos
COPY --from=build /go/release/egg ./egg

COPY --from=build /go/release/etc/cfg.yml /var/zyos/cfg.yml
COPY --from=build /go/release/etc/cfg.yml /var/egg/cfg.yml

# 启动服务
CMD ["./zyos","-c","/var/zyos/cfg.yml"]
CMD ["./egg","-c","/var/egg/cfg.yml"]


+ 7
- 7
go.mod Datei anzeigen

@@ -2,9 +2,9 @@ module applet

go 1.19

replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models
replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules
//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models
//
//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules

require (
github.com/boombuler/barcode v1.0.1
@@ -34,11 +34,13 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241112135742-0200baa0a923
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.2
code.fnuoos.com/EggPlanet/egg_models.git v0.0.2
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.3
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
github.com/go-sql-driver/mysql v1.8.1
github.com/gocolly/colly v1.2.0
github.com/shopspring/decimal v1.3.1
github.com/tidwall/gjson v1.14.1
)

@@ -47,7 +49,6 @@ require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/PuerkitoBio/goquery v1.9.2 // indirect
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/antchfx/htmlquery v1.3.3 // indirect
github.com/antchfx/xmlquery v1.4.2 // indirect
@@ -85,7 +86,6 @@ require (
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/streadway/amqp v1.0.0 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/temoto/robotstxt v1.1.2 // indirect


+ 20
- 20
k8s/container.yaml Datei anzeigen

@@ -2,25 +2,25 @@ kind: Deployment
apiVersion: apps/v1
# 元数据
metadata:
name: advertisement
namespace: advertisement
name: egg-admin
namespace: egg
labels:
app: advertisement
app: egg-admin
annotations:
kubesphere.io/creator: dengbiao
kubesphere.io/description: advertisement
kubesphere.io/description: egg-admin
# deployment主要部分
spec:
replicas: 1
selector:
matchLabels:
# 名称与上面的labels对应
app: advertisement
app: egg-admin
template:
metadata:
labels:
# 名称与上面的matchLabels对应
app: advertisement
app: egg-admin
spec:
# 声明挂载卷(将外部已存在的pvc、config等挂载进来)
volumes:
@@ -30,41 +30,41 @@ spec:
path: /etc/localtime
type: ''
# 将前面创建的configMap也挂载进来
- name: advertisement-cfg
- name: egg-admin-cfg
configMap:
# 这里的名字就是前面创建的configMap的名字
name: advertisement-cfg
name: egg-admin-cfg
defaultMode: 420
# pvc
- name: advertisement # 在该部署中的名称,后面使用改名称挂载
- name: egg-admin # 在该部署中的名称,后面使用改名称挂载
persistentVolumeClaim:
claimName: advertisement # pvc的名称
claimName: egg-admin # pvc的名称
# Nginx配置
- name: advertisement-nginx
- name: egg-admin-nginx
configMap:
name: advertisement-nginx # 外部configMap的名称
name: egg-admin-nginx # 外部configMap的名称
items:
- key: go.conf
path: default.conf
containers:
# 主容器
- name: advertisement-container
- name: egg-admin-container
# 镜像地址(提前打包好并推送的镜像仓库)
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/advertisement:0.0.1'
image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/egg-admin:0.0.1'
ports:
- name: ad-1002
- name: egg-admin-4001
# 容器端口号(注意与golang web server启动的端口一致)
containerPort: 1002
containerPort: 4001
protocol: TCP
# 将前面volume声明的需要用到的pvc、config挂载上来
volumeMounts:
- name: host-time
readOnly: true
mountPath: /etc/localtime
- name: advertisement-cfg # 该名字对应前面volumes声明的名字
- name: egg-admin-cfg # 该名字对应前面volumes声明的名字
readOnly: true
# 挂载到容器的哪个路径
mountPath: /var/zyos
mountPath: /var/egg
imagePullPolicy: Always
# Nginx 容器
- name: nginx
@@ -79,9 +79,9 @@ spec:
readOnly: true
mountPath: /etc/localtime
# 存储卷 用于存放前端代码
- name: advertisement # 前面volumes声明的名称
- name: egg-admin # 前面volumes声明的名称
mountPath: /usr/share/nginx/html
- name: advertisement-nginx # Nginx 配置
- name: egg-admin-nginx # Nginx 配置
readOnly: true
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf


+ 17
- 0
k8s/ingress.yaml Datei anzeigen

@@ -0,0 +1,17 @@
kind: Ingress
apiVersion: extensions/v1beta1
metadata:
name: advertisement # ingress名称
namespace: advertisement
annotations:
kubesphere.io/creator: dengbiao
spec:
rules:
- host: 123456.advertisement.dengbiao.top # 使用的域名
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: advertisement # 流量转发到的服务
servicePort: 80

+ 20
- 0
k8s/ingress_prd.yaml Datei anzeigen

@@ -0,0 +1,20 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
kubesphere.io/creator: dengbiao
name: advertisement
namespace: advertisement
spec:
rules:
- host: '*.adcms.zhiyingos.cn'
http:
paths:
- backend:
service:
name: advertisement
port:
number: 80
path: /
pathType: ImplementationSpecific

Laden…
Abbrechen
Speichern