Skip to content

Commit 6fa311c

Browse files
yangmvyangmv
authored andcommitted
更新dockerfile
1 parent 956281b commit 6fa311c

File tree

3 files changed

+79
-19
lines changed

3 files changed

+79
-19
lines changed

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ ADD . /var/www/CMDB/
2121
RUN pip3 install --user --upgrade pip
2222
RUN pip3 install -r /var/www/CMDB/requirements.txt
2323

24-
# 5. 数据初始化
24+
# 5.准备配置文件
25+
RUN cp /var/www/CMDB/cmdb-example.conf /var/www/CMDB/cmdb.conf
26+
27+
# 6. 数据初始化
2528
RUN python3 /var/www/CMDB/manage.py makemigrations
2629
RUN python3 /var/www/CMDB/manage.py migrate
2730

28-
# 6. 日志
31+
# 7. 日志
2932
VOLUME /var/log/
3033

31-
# 7. 准备文件
34+
# 8. 准备文件
3235
COPY docs/supervisor_cmdb.conf /etc/supervisord.conf
3336
COPY docs/nginx_cmdb.conf /etc/nginx/conf.d/
3437

Jenkinsfile

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,26 @@ node('haimaxy-jnlp') {
77
}
88
}
99
stage('Test') {
10-
echo "2.代码测试[PAAS]"
10+
echo "2.代码测试[PAAS]"
1111
}
1212
stage('Build') {
1313
echo "3.构建打包 Docker 镜像"
14-
sh "docker build -t harbor-k8s.shinezone.com/ops/flask-demo:${build_tag} ."
14+
sh "docker build -t harbor-k8s.shinezone.com/ops/codo-cmdb:${build_tag} ."
1515
}
1616
stage('Push') {
1717
echo "4.推送 Docker 镜像到仓库"
1818
withCredentials([usernamePassword(credentialsId: 'dockerHubSZ', passwordVariable: 'dockerHubSZPassword', usernameVariable: 'dockerHubSZUser')]) {
1919
sh "docker login -u ${dockerHubSZUser} -p ${dockerHubSZPassword} https://harbor-k8s.shinezone.com"
20-
sh "docker push harbor-k8s.shinezone.com/ops/flask-demo:${build_tag}"
20+
sh "docker push harbor-k8s.shinezone.com/ops/codo-cmdb:${build_tag}"
2121
}
2222
}
2323
stage('YAML') {
2424
echo "5.YAML配置"
25-
sh "sed -i 's/<BUILD_TAG>/${build_tag}/' flask-demo-deploy.yaml"
26-
sh "sed -i 's/<PORT>/${port}/' flask-demo-deploy.yaml"
27-
sh "sed -i 's/<PORT>/${port}/' flask-demo-ingress.yaml"
28-
sh "sed -i 's/<DOMAIN>/${domain}/' flask-demo-ingress.yaml"
25+
sh "sed -i 's/<BUILD_TAG>/${build_tag}/' deploy.yaml"
26+
sh "sed -i 's/<DOMAIN>/${domain}/' deploy.yaml"
2927
}
3028
stage('Deploy') {
3129
echo "6.开始部署"
32-
//if (userInput == "Dev") {
33-
//sh "kubectl apply -f flask-demo-deploy.yaml -n dev"
34-
//} else if (userInput == "QA"){
35-
//sh "kubectl apply -f flask-demo-deploy.yaml -n qa"
36-
//} else {
37-
//sh "kubectl apply -f flask-demo-deploy.yaml -n release"
38-
//}
39-
sh "kubectl apply -f flask-demo-deploy.yaml -n ${namespace}"
40-
sh "kubectl apply -f flask-demo-ingress.yaml -n ${namespace}"
30+
sh "kubectl apply -f deploy.yaml -n ${namespace}"
4131
}
4232
}

deploy.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: codo-cmdb
5+
spec:
6+
replicas: 2
7+
selector:
8+
matchLabels:
9+
app: codo-cmdb
10+
template:
11+
metadata:
12+
labels:
13+
app: codo-cmdb
14+
spec:
15+
containers:
16+
- name: codo-cmdb
17+
image: harbor-k8s.shinezone.com/ops/codo-cmdb:<BUILD_TAG>
18+
imagePullPolicy: IfNotPresent
19+
# lifecycle:
20+
# postStart:
21+
# exec:
22+
# command: ['/bin/sh', '-c', 'sed -i "s/s_hostname/$(hostname)/" /data1/www/templates/app.html']
23+
ports:
24+
- name: http
25+
containerPort: <PORT>
26+
volumeMounts:
27+
- name: cmdbconf
28+
mountPath: /var/www/CMDB/
29+
readOnly: true
30+
volumes:
31+
- name: cmdbconf
32+
configMap:
33+
name: cmdb-conf
34+
35+
---
36+
apiVersion: v1
37+
kind: Service
38+
metadata:
39+
name: codo-cmdb
40+
labels:
41+
app: codo-cmdb
42+
spec:
43+
selector:
44+
app: codo-cmdb
45+
#type: NodePort
46+
type: ClusterIP
47+
ports:
48+
- name: http
49+
port: 80
50+
targetPort: 80
51+
52+
---
53+
apiVersion: extensions/v1beta1
54+
kind: Ingress
55+
metadata:
56+
name: codo-cmdb-ingress
57+
annotations:
58+
kubernetes.io/ingress.class: "nginx"
59+
spec:
60+
rules:
61+
- host: <DOMAIN>
62+
http:
63+
paths:
64+
- path:
65+
backend:
66+
serviceName: codo-cmdb
67+
servicePort: 80

0 commit comments

Comments
 (0)