增加docker文件

This commit is contained in:
wulin 2025-03-22 19:39:45 +08:00
parent 340424f945
commit c185ae9725
3 changed files with 103 additions and 0 deletions

80
docker/deploy/deploy.yaml Normal file
View File

@ -0,0 +1,80 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: $JAVA_MODEL
name: $JAVA_MODEL
namespace: $DOCKERHUB_NAMESPACE #一定要写名称空间 由jenkinsfile通过sed命令替换
spec:
progressDeadlineSeconds: 600
replicas: 1
selector:
matchLabels:
app: $JAVA_MODEL
strategy:
rollingUpdate:
maxSurge: 50%
maxUnavailable: 50%
type: RollingUpdate
template:
metadata:
labels:
app: $JAVA_MODEL
spec:
imagePullSecrets:
- name: $DOCKER_CREDENTIAL_ID #提前在k8s的DevOps项目下配置访问镜像服务的账号密码
containers:
- image: $REGISTRY/$DOCKERHUB_NAMESPACE/$DOCKERHUB_NAMESPACE:$JAVA_MODEL-$SNAPSHOT-v$BUILD_NUMBER #$开头的都将在cicd中通过sed指令替换
readinessProbe:
httpGet:
path: /actuator/health
port: $SERVER_PORT
timeoutSeconds: 30
failureThreshold: 30
periodSeconds: 20
imagePullPolicy: Always
name: app
ports:
- containerPort: $SERVER_PORT
protocol: TCP
resources:
requests: #资源请求的设置
memory: 1024Mi #内存清楚,容器启动的初始可用数量
limits:
memory: 1024Mi
volumeMounts:
- mountPath: /home/heyu/logs
name: api-logs
- name: host-time
readOnly: true
mountPath: /etc/localtime
terminationMessagePath: /nfs/data/heyu/api/logs
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
volumes:
- name: api-logs
hostPath:
path: /nfs/data/heyu/api/logs
- name: host-time
hostPath:
path: /etc/localtime
---
apiVersion: v1
kind: Service
metadata:
labels:
app: $JAVA_MODEL
name: $JAVA_MODEL
namespace: $DOCKERHUB_NAMESPACE
spec:
ports:
- name: http
port: $SERVER_PORT
protocol: TCP
targetPort: $SERVER_PORT
selector:
app: $JAVA_MODEL
sessionAffinity: None
type: ClusterIP

22
docker/dockerfile Normal file
View File

@ -0,0 +1,22 @@
# 基础镜像
FROM harbor.iwulin.tech/devops/openjdk11:jre-11.0.26_4
# author
MAINTAINER heyu
# 挂载目录
VOLUME /home/heyu
# 创建目录
RUN mkdir -p /home/heyu
# 指定路径
WORKDIR /home/heyu
# 复制jar文件到路径 $JAVA_MODEL为变量通过jenkins sed 修改
COPY jar/$JAVA_MODEL.jar /home/heyu/$JAVA_MODEL.jar
# 创建目录 拷贝IP地址数据库
RUN if ["$JAVA_MODEL" = "api-user-api"]; then \
mkdir -p /home/heyu/ip-database; \
fi
#COPY_IP
# 启动网关服务
#ENTRYPOINT ["java","-jar","api-websocket-api.jar"]
CMD ["sh","-c", "java -jar $JAVA_MODEL.jar --spring.profiles.active=$ACTIVE"]

View File

@ -0,0 +1 @@
别删