The current front-end code deployment mode login Jenkins system, click the corresponding project to complete the deployment of the corresponding front-end project

Code building process

Code construction process (front-end project construction and image generation and push to Docker image Ali Cloud private server)

1 Configure source management

  • Specify the Repository URL for the GitLab project
  • Configure the publishing branch of the corresponding task
  • Execute the corresponding shell script after completing the corresponding code pull
  •         EnvType is the corresponding environment parameter, later need to inform dockerfile current environment
    	docker build --build-arg envType=dev -t projectName .
     	# currently logged in docker image Ali Cloud private server
    	docker login --username=username --password=password registry-vpc.cn-hangzhou.aliyuncs.com
    	Back up the current tag imageDocker tag project name registry-vpc.cn-hangzhou.aliyuncs.com/ warehouse/project name# Push the packed image to ali Cloud private serverDocker push registry-vpc.cn-hangzhou.aliyuncs.com/ warehouse name/project nameCopy the code

    Deployment code process

    Deployment code process (mirroring and startup of the corresponding environment from Ali Cloud Private server pull)

    	# currently logged in docker image Ali Cloud private server
    	docker login -u username -p password registry-vpc.cn-hangzhou.aliyuncs.com
    	Stop the current container
    	docker stop projectName
    	Delete the corresponding container
    	docker rm -f projectName
    	Delete the front-end project image of the corresponding machineDocker rmi registry-vpc.cn-hangzhou.aliyuncs.com/ warehouse name/project name# Pull the front end project image corresponding to the Docker Ali Cloud private server warehouseDocker pull registry-vpc.cn-hangzhou.aliyuncs.com/ warehouse name/project name# start container
    	docker run -d-p External port: internal port --name Container name registry-vpc.cn-hangzhou.aliyuncs.com/hc-ad/adopCopy the code

    Docker build –build-arg envType=dev -t projectName

    	# build from the latest version of NODE container
    	FROM node:alpine
    	Define environment variables
    	ARG envType=default_value
    	Get the environment variable passed in by the shell command
    	ENV envType ${envType}
    	# Switch domestic Docker image sourceThe RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g'/etc/apk/repositories' # copy./package.json /app/ WORKDIR /app # Registry https://registry.npm.taobao.org # download production depends on the RUN NPM install - production # and copy to the corresponding working directory copy. The RUN/app # front-end code execution / CMD $environment NPM run PRD /# EXPOSE portCopy the code