Commit 76e314e9 authored by 蔡漂平's avatar 蔡漂平

devops

parent 009deb74
#!/usr/bin/groovy
@Library('pipeline-library')
def utils = new io.fabric8.Utils()
clientsNode{
def env = 'shanghaiwuye'
def projectName = "${JOB_BASE_NAME}"
def newVersion = ''
def deployType = ""
try {
deployType = DEPLOY_TYPE
} catch (Throwable e) {
deployType = "TEST"
}
checkout scm
stage '构建版本'
echo 'NOTE: running pipelines for the first time will take longer as build and base docker images are pulled onto the node'
if (!fileExists ('Dockerfile')) {
writeFile file: 'Dockerfile', text: '''FROM 168.168.112.64:5000/node-nginx:8.12.0
WORKDIR /app
# 将当前目录下的所有文件拷贝到工作目录下
COPY . /app/
# 1.安装依赖
# 2.运行 npm run build
# 3.将 dist 目录的所有文件拷贝到 nginx 的目录下
# 4.删除工作目录的文件,尤其是 node_modules 以减小镜像体积
# 由于镜像构建的每一步都会产生新层
# 为了减小镜像体积,尽可能将一些同类操作,集成到一个步骤中,如下、
RUN cp -r dist/* /var/www/html \\
&& cp nginx.conf /etc/nginx/conf.d \\
'''
}
newVersion = performCanaryRelease {}
def rc = getKubernetesJson {
port = 80
label = 'nodejs'
version = newVersion
name = projectName
imageName = clusterImageName
}
stage '部署'
kubernetesApply(file: rc, environment: env)
}
server {
listen 80;
server_name localhost;
#vue项目的打包后的dist
root /var/www/html;
location / {
try_files $uri $uri/ @router;#需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
index index.html index.htm;
}
#对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
#因此需要rewrite到index.html中,然后交给路由在处理请求资源
location @router {
rewrite ^.*$ /index.html last;
}
}
\ No newline at end of file
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