先来看整体架构图,分为构建和部署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