简单搭建CICD前端自动化构建平台

2.给予执行权限
sudo chmod +x /usr/local/bin/docker-compose

3.测试命令
docker-compose --version
docker-compose version 1.23.2, build 1110ad01

更换源:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://9qfku0yo.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
systemctl restart docker
systemctl daemon-reload

  • 安装gitlab-runner
  • 在docker里面注册docker
image: node:16.3.0

stages:
 - install
 - build
 - deploy
cache:
  key: vitepro
  paths:
    - node_modules
    
job_install:
  stage: install
  tags:
    - docker
  script:
    - npm config set registry http://registry.npm.taobao.org/
    - npm install
    
job_build:
  stage: build
  tags:
    - docker
  script:
    - npm run build
  artifacts:
    paths:
      - dist/
    
job_deploy:
  stage: deploy
  image: docker
  tags:
    - docker
  script:
    - echo 'deploy'
    - docker build -t jenkinsvue .
    - if [ $(docker ps -aq --filter name=myvite-container) ]; then docker rm -f myvite-container;fi
    - docker run -d -p 8082:80 --name myvite-container jenkinsvue

job_deploy_oss:
  stage: deploy
  tags:
    - docker
  script:
    - wget http://gosspublic.alicdn.com/ossutil/1.6.18/ossutil64
    - chmod 755 ossutil64
    - ./ossutil64 config -e ${endPoint} -i ${accessKeyID} -k ${accessKeySecret} -L CH --loglevel debug -c ~/.ossutilconfig
    - ls
    - pwd
    - ./ossutil64 -c ~/.ossutilconfig cp -r -f dist oss://bucketdem/
  when: manual
FROM node:16.3.0 as builder
WORKDIR /app
COPY package.json .
RUN npm install --registry=http://registry.npm.taobao.org
COPY . .
RUN npm run build

FROM nginx:latest
COPY --from=builder /app/dist /usr/share/nginx/html
上一篇:fabric docker-compose 环境设置


下一篇:Docker-Compose