1. 程式人生 > 其它 >簡單搭建CICD前端自動化構建平臺

簡單搭建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