微服务小范围发布影响小

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微服务小范围发布影响小相关的知识,希望对你有一定的参考价值。

1 看下项目结构,技术分享图片首先要有dockerfile,
FROM git.we3tu.com:5000/tomcatmaven:latest
RUN apk --update add wget
RUN mkdir -p /usr/src/app
RUN mkdir -p /usr/scripts
RUN mkdir -p /www
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN unzip /usr/src/app/target/visa.war -d /opt/tomcat/webapps/ROOT
RUN cp /usr/src/app/start.sh /usr/scripts
RUN rm -rf /usr/src/app

ENTRYPOINT ["/bin/sh","/usr/scripts/start.sh"]

2 关于应用的配置文件用变量传递下载到测试环境或生产环境
vim start.sh
#! /bin/sh
wget http://$DOMAIN_ENV.config.we3tu.com/$PROJECTNAME/dev/application.properties -O /opt/tomcat/webapps/ROOT/WEB-INF/classes/dev/application.properties 测试环境配置文件路径
wget http://$DOMAIN_ENV.config.we3tu.com/$PROJECTNAME/pro/application.properties -O /opt/tomcat/webapps/ROOT/WEB-INF/classes/pro/application.properties 生产环境配置文件路径
wget http://$DOMAIN_ENV.config.we3tu.com/$PROJECTNAME/applicationContext.xml -O /opt/tomcat/webapps/ROOT/WEB-INF/classes/applicationContext.xml
/opt/tomcat/bin/catalina.sh run
3 vim .gitlab-ci.yml
stages:

  • build
  • deploy

variables:
PROJECT_NAME: visa

build_test_docker:
stage: build
script:

  • mvn package -Dmaven.test.skip=true
  • docker build -f Dockerfile -t $PROJECT_NAME .
  • docker tag $PROJECT_NAME git.we2tu.com:5000/$PROJECT_NAME:$CI_COMMIT_REF_NAME
  • docker push git.we3tu.com:5000/$PROJECT_NAME:$CI_COMMIT_REF_NAME
    tags:
  • cyjavatest
    only:
  • /^release-*/

deploy_test_docker:
stage: deploy
script:

  • docker stack deploy -c deploy/deploy.test.yml visa_service_test
    tags:
  • cyjavatest
    only:
  • /^release-*/

build_master_docker:
stage: build
script:

  • mvn clean package -Dmaven.test.skip=true
  • docker build -f Dockerfile -t $PROJECT_NAME .
  • docker tag $PROJECT_NAME git.we2tu.com:5000/$PROJECT_NAME:$CI_COMMIT_REF_NAME
  • docker tag $PROJECT_NAME git.we2tu.com:5000/$PROJECT_NAME:latest
  • docker push git.we3tu.com:5000/$PROJECT_NAME:$CI_COMMIT_REF_NAME
  • docker push git.we3tu.com:5000/$PROJECT_NAME:latest
    tags:
  • erpjavabuild
    only:
  • master

deploy_prod_docker:
stage: deploy
script:

  • docker stack deploy -c deploy/deploy.prod.yml visa_service
    tags:
  • erpprodshell
    only:
  • master
    4 部署的路径怎么部署:
    vim deploy.test.yml
    version: ‘3‘
    services:
    visa_service_test:
    image: git.we3tu.com:5000/$PROJECT_NAME:$CI_COMMIT_REF_NAME
    environment:
    • "DOMAIN_ENV=test"
    • "PROJECTNAME=visa"
    • "QUARTZ_ENV=noquartz"
      logging:
      driver: syslog
      options:
      syslog-address: "tcp://x.x.x.x:5514"
      tag: $PROJECT_NAME
      ports:
    • 8021:8080
      deploy:
      replicas: 1
      update_config:
      parallelism: 1
      delay: 10s
      restart_policy:
      condition: any
      networks:
    • docker-cy-test
      networks:
      docker-cy-test:
      external: true

5 vim deploy.prod.yml
version: ‘3‘
services:
visa_service:
image: git.we3tu.com:5000/$PROJECT_NAME:$CI_COMMIT_REF_NAME
environment:

  • "DOMAIN_ENV=prod"
  • "PROJECTNAME=visa"
  • "QUARTZ_ENV=noquartz"
    logging:
    driver: json-file
    ports:
  • 8021:8080
    deploy:
    replicas: 2
    update_config:
    parallelism: 1
    delay: 10s
    restart_policy:
    condition: any
    max_attempts: 10
    networks:
  • prod-net
    networks:
    prod-net:
    external: true

以上是关于微服务小范围发布影响小的主要内容,如果未能解决你的问题,请参考以下文章

度小满启动“小微加油站”,让低息服务可持续

GitHub突发网络劫持;MacOS蓝牙漏洞可无接触利用;微信分付小范围上线

用Centos7搭建小微企业Samba文件共享服务器

品钛与多家零售SAAS服务商合作 小微企业信贷解决方案全面赋能新零售

easywechat微信开发SDK之小微商户进件

什么是地图发布服务中间件(WeServer)