Commit 7e5d9f79 authored by 郭铭瑶's avatar 郭铭瑶 🤘

Merge branch 'public' of http://git.omniview.pro/yaominguo/yangpu into public

parents 24d01b1d 03467191
FROM 10.0.6.228:5000/node-nginx:8.12.0-slim
WORKDIR /app
COPY . /app/
RUN npm config set proxy=http://10.0.6.228:3128 && npm set registry https://registry.npm.taobao.org && npm install && npm run build && cp -r dist/* /var/www/html && cp nginx.conf /etc/nginx/conf.d && rm -rf /etc/nginx/sites-enabled && rm -rf /app
pipeline {
agent {
node {
label 'nodejs'
}
}
environment {
KUBECONFIG_CREDENTIAL_ID = 'devops-kubeconfig'
REGISTRY = '10.0.6.228:5000'
DOCKERHUB_NAMESPACE = 'house-manage-yp'
APP_NAME = 'web-street'
NAMESPACE = 'house-manage-yp'
}
stages {
stage ('checkout scm') {
steps {
checkout(scm)
}
}
stage ('build & push') {
steps {
container ('nodejs') {
sh 'docker build -f Dockerfile -t $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$BUILD_NUMBER .'
sh 'docker push $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$BUILD_NUMBER'
}
}
}
stage('deploy') {
steps {
kubernetesDeploy(configs: 'deploy/**', enableConfigSubstitution: true, kubeconfigId: "$KUBECONFIG_CREDENTIAL_ID")
}
}
}
}
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: $APP_NAME
name: $APP_NAME
namespace: $NAMESPACE
spec:
progressDeadlineSeconds: 600
replicas: 1
selector:
matchLabels:
app: $APP_NAME
template:
metadata:
labels:
app: $APP_NAME
spec:
containers:
- image: $REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME:$BUILD_NUMBER
imagePullPolicy: Always
name: $APP_NAME
readinessProbe:
httpGet:
path: /
port: 80
timeoutSeconds: 10
failureThreshold: 30
periodSeconds: 5
ports:
- containerPort: 80
protocol: TCP
resources:
limits:
cpu: 200m
memory: 500Mi
requests:
cpu: 100m
memory: 100Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
labels:
app: $APP_NAME
name: $APP_NAME
namespace: $NAMESPACE
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
app: $APP_NAME
sessionAffinity: None
type: ClusterIP
server {
listen 80;
server_name localhost;
#vue项目的打包后的dist
root /var/www/html;
location / {
add_header Access-Control-Allow-Origin *;
add_header X-Frame-Options ALLOWALL;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
}
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment