先來看整體架構圖,分爲構建和部署node
.gitlab-ci.ymlgit
stages: - test - deploy # 變量 variables: DEV_RSYNC_PATH: "/data/deploy/xunlei.com/misc.xl9.xunlei.com/d/" # 全部 stage 以前的操做 before_script: - npm set registry http://xnpm.sz.xunlei.cn - npm install # 代碼檢查 lint: stage: test script: npm run lint # 單元測試 unit: stage: test script: npm run unit # 部署測試服務器 deploy_dev: stage: deploy tags: - 10.10.34.91-dev only: - develop script: - rsync -av --delete-after --exclude-from=/data/shell/home.xl9.xunlei_exclude.list . $DEV_RSYNC_PATH - chmod -R 755 $DEV_RSYNC_PATH - chown -R nobody:nobody $DEV_RSYNC_PATH - find $DEV_RSYNC_PATH -type f -exec chmod 644 {} \; - cd $DEV_RSYNC_PATH - npm install
例如:docker
FROM ubuntu RUN apt-get update && apt-get install -y nodejs ADD . /app RUN cd /app && npm install CMD npm start