Commit 95682ac8 authored by 江兵's avatar 江兵

cicd

parent 7c2a2388
Pipeline #3261 passed with stages
in 2 minutes and 44 seconds
variables:
NANGAO_BASE_IMAGE: "$CI_REGISTRY/nangao-iot/nangao-base"
VS_WEB_IMAGE: "$CI_REGISTRY/nangao-iot/vs-web"
VS_WEB_BASE_IMAGE: "$CI_REGISTRY/nangao-iot/vs-web-base"
vs-base:
image: $NANGAO_BASE_IMAGE
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build -f ./Dockerfile_base -t $VS_WEB_BASE_IMAGE .
- docker push $VS_WEB_BASE_IMAGE
when: manual
vs-web-dev:
image: $NANGAO_BASE_IMAGE
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build -f ./Dockerfile_web_dev -t "$VS_WEB_IMAGE"-dev .
- docker push "$VS_WEB_IMAGE"-dev
only:
changes:
- src/**/*
- config/**/*
#发布到开发环境
deploy_dev:
stage: deploy
image: $NANGAO_BASE_IMAGE
services:
- docker:dind
before_script:
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- ssh-add <(echo "$PRIVATE_KEY")
script:
- rsync -Phvz -e "ssh -p 6005" ./docker-compose-dev.yaml root@$DEV_IP:/root/docker-compose/vslp/docker-compose.yaml
- ssh -p 6005 $DEV_IP 'cd /root/docker-compose/vslp; docker-compose pull vs_web;docker-compose up -d '
# 环境
FROM node:19.6.1-alpine3.17 AS build-env
USER root
ENV SRC_HOME=/root/src
RUN mkdir -p $SRC_HOME
# 复制源代码
ADD . $SRC_HOME/
WORKDIR $SRC_HOME/
RUN yarn
\ No newline at end of file
# 环境
FROM swr.cn-north-4.myhuaweicloud.com/nangao-iot/vs-web-base AS build-env
USER root
ENV SRC_HOME=/root/src
RUN mkdir -p $SRC_HOME
# 复制源代码
ADD . $SRC_HOME/
WORKDIR $SRC_HOME
RUN yarn
RUN npm run build:dev
# Second stage - build image
FROM nginx
COPY --from=build-env /root/src/dist/ /usr/share/nginx/html/
#设置时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
#PORT
ENV SERVER_PORT 80
EXPOSE ${SERVER_PORT}
\ No newline at end of file
version: '2.2'
services:
vs_web:
image: swr.cn-north-4.myhuaweicloud.com/nangao-iot/vs-web-dev
container_name: vs_web
restart: always
ports:
- "8999:80"
volumes:
- /etc/localtime:/etc/localtime:ro
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment