gitlab ci 部署vue项目

记录一下其中的三个配置文件。

.gitlab-ci.yml

image: xxx/docker/node:10.12.0-alpine

stages:
  - build
  - deploy

cache:
  key: ${CI_COMMIT_REF_NAME}
  paths:
   - node_modules/

job-build:
  stage: build
  only:
    - master
    - feature/init
  tags:
    - shell
  script:
    - npm set registry https://registry.npm.taobao.org
    - npm install --progress=false
    - npm run build
  artifacts:  
    expire_in: 1 week
    paths:
      - dist

job-release:
  stage: deploy
  only:
    - master
  tags:
    - shell
  script:
    - docker build -t xxx/dashboard/dashboard:${CI_COMMIT_SHA:0:8} .
    - docker login -u $DOCKER_USER -p $DOCKER_PASSWORD docker-registry.xxx 
    - docker push xxx/dashboard/dashboard:${CI_COMMIT_SHA:0:8}
  when: manual

Dockerfile

FROM xxx/docker/nginx:1.13.6
COPY ./dist /var/www/html
COPY ./im-dashboard.conf /etc/nginx/conf.d/ 
RUN rm /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx","-g","daemon off;"]

im-dashboard.conf

server {
    listen 80;
    listen [::]:80;
    # 接口服务的IP地址
    server_name im-dashboard.xxx;
    charset utf-8;
    access_log off;
    # ElecManageSystem-应用文件夹名称 app-index.html页面所在文件夹
    root /var/www/html;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
    }

    location /getChartData {
        proxy_pass http://xxx/c/dashboard/getChartData;
        proxy_set_header Cookie $http_cookie;
    }
    location /getMetricNameMap {
        proxy_pass http://xxx/c/dashboard/getMetricNameMap;
        proxy_set_header Cookie $http_cookie;
    }
    location /getGradeList {
        proxy_pass http://xxx/c/dashboard/getGradeList;
        proxy_set_header Cookie $http_cookie;
    }

    location /initQuery {
        proxy_pass http://xxx/c/projectListener/initQuery;
        proxy_set_header Cookie $http_cookie;
    }

    location /getTotalLayer {
        proxy_pass http://xxx/c/Metric/getTotalLayer;
        proxy_set_header Cookie $http_cookie;
    }

    location /findGroupByPidAndPager {
        proxy_pass http://xxx/api/group/findGroupByPidAndPager;
    }

    location /findHostBygroupId {
        proxy_pass http://xxx/api/group/findHostBygroupId;
    }

    location /v1 {
        proxy_pass http://xxx/api/v1;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }
}

你可能感兴趣的:(gitlab ci 部署vue项目)