欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Portainer ce管理容器的操作過程

 更新時(shí)間:2025年07月09日 14:41:33   作者:localhost@c_sdn  
這篇文章主要介紹了Portainer ce管理容器的操作過程,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

1、啟動(dòng) java 后端服務(wù)

1.1、手動(dòng)構(gòu)建鏡像

先把 java應(yīng)用程序打成 jar 包,放到指定目錄

通過Dockerfile 打成鏡像

# 鏡像倉庫的地址訪問地址 harbor.hkc.cn
FROM harbor.hkc.cn/jpaas/openjdk_base:8

# 郵箱
MAINTAINER hw@hkc.cn

RUN   ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone

USER root

WORKDIR /

#導(dǎo)入編譯后的jar包
ADD  target/hkc-eip.jar   /jpaas-eip.jar

#暴露端口 不是實(shí)際運(yùn)行端口
EXPOSE 9900

#啟動(dòng)命令  占位符
CMD java $JAVA_OPTS $APPLICTION_OPTS -jar /jpaas-eip.jar

執(zhí)行構(gòu)建命令

# 把jar包和Dockerfile 放在同一層目錄
docker build -t harbor.hkc.cn/eip/jpass-eip:v3 .

# 先登錄到鏡像服務(wù)器  登錄遠(yuǎn)程
docker login harbor.hkc.cn

# 推送鏡像  docker push 鏡像名:標(biāo)簽名
docker push harbor.hkc.cn/eip/jpaas-eip:v3

# 鏡像倉庫地址:查看是否推送
https://xxxx.xxxx.xxxx.xxxx/harbor/

1.1、gitlab 流水線構(gòu)建鏡像

前提條件:

  • 1、配置了gitrunner 來監(jiān)聽這個(gè)分支。
  • 2、maven 鏡像連接遠(yuǎn)程能下載的。

項(xiàng)目里面需要配置 Dockerfile   .gitlab-ci.yml  這個(gè)兩個(gè)文件

Dockerfile   文件內(nèi)容(可能會(huì)跟手動(dòng)鏡像的不一樣。路徑問題)

FROM harbor.hkc.cn/jpaas/openjdk_base:8

MAINTAINER liuli@hkc.cn

RUN   ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone

USER root

WORKDIR /

#導(dǎo)入編譯后的jar包
ADD  target/hkc-eip.jar   /jpaas-eip.jar

#暴露端口
EXPOSE 9900

#啟動(dòng)命令
CMD java $JAVA_OPTS $APPLICTION_OPTS -jar /jpaas-eip.jar

.gitlab-ci.yml 文件內(nèi)容

image: harbor.hkc.cn/jpaas/cibase:0.8.1
stages:
  - maven
  - deploy

# 當(dāng)前路徑均為 .gitlab-ci.yml文件所在目錄
maven_job:
  stage: maven
  tags:
    - default
  # 指定分支
  only:
    - eip_release_git
    # - eip_release
    # - eip_dev
    # - eip_test
  script:
    - echo "maven job maven version"
    - mkdir -p /root/gitrunner/$CI_PROJECT_NAME
    - cd ./hkc-eip/
    - mvn clean package -DskipTests=true
    # 需要?jiǎng)h除定時(shí)任務(wù) job 相關(guān)代碼
    - mkdir ./target/hkc-eip
    - cd ./target/hkc-eip
    - jar -xvf ../hkc-eip.jar
    # 刪除不用的 job 文件夾
    - rm -rf ./BOOT-INF/classes/com/redxun/job
    - rm -rf ./BOOT-INF/classes/mapper/job
    # 壓縮文件
    - jar -cvfM0 hkc-eip.jar ./
    - cd ..
    #- echo "pwd"   /builds/hkc-eip/hkc-eip-server/hkc-eip/target
    #- pwd
    # 刪除舊的
    - rm -rf ../target/hkc-eip.jar
    # 把新的替換過來
    - mv ../target/hkc-eip/hkc-eip.jar ../target/
    - echo "ls"
    - ls
    - rm -rf ./target/hkc-eip
    - cd ..
    - cp -f ./target/*.jar /root/gitrunner/$CI_PROJECT_NAME/

  cache:
    paths:
      - .m2/repository
  # artifacts:
  #   expire_in: 3 hrs
  #   paths:
  #     - ./target/hkc-eip.jar

deploy_job:
  stage: deploy
  image: docker:stable
  variables:
    DOCKER_TLS_CERTDIR: ""
    GODEBUG: "x509ignoreCN=0"
    DOCKER_HOST: "tcp://docker:2375"
  services:
    - name: docker:19.03.8-dind
      alias: docker
      command:
        - "--insecure-registry=harbor.hkc.cn"
  tags:
    - default
  # 指定分支
  only:
    - eip_release_git
    # - eip_release
    # - eip_dev
    # - eip_test
  script:
    - datetime=`date +%Y%m%d%H%M%S`
    - echo "set now datetime"
    - echo $datetime
    - ls -al /root/gitrunner
    - echo "set branch name CI_PROJECT_NAME"
    # - CI_BRANCH_NAME=`git symbolic-ref --short -q HEAD`
    - echo $CI_PROJECT_NAME
    - mkdir target && cp -f /root/gitrunner/$CI_PROJECT_NAME/*.jar ./target/
    - docker login harbor.hkc.cn -u 0179733 -p Qweasd123
    # 注意 Dockerfile 和 nginx 的配置文件的位置
    - docker build -t harbor.hkc.cn/eip/jpaas-eip:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA-$datetime -f ./hkc-eip/Dockerfile .
    - docker push harbor.hkc.cn/eip/jpaas-eip:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA-$datetime
  after_script:
    - rm -rf /root/gitrunner/$CI_PROJECT_NAME

啟動(dòng)服務(wù):

在 portainer ce 上配置堆棧啟動(dòng)

去 鏡像倉庫找到最新的鏡像文件

jpaas-eip-server.yml 啟動(dòng)文件信息

version: '3.7'
services:
  jpaas-eip-server:
    # 鏡像名  :點(diǎn)進(jìn)鏡像看里面具體的名稱
    image: harbor.hkc.cn/eip/jpaas-eip:eip_release_git-c4ace4ed-20240429020258
    # 容器名
    container_name: jpaas-eip-server
    # 主機(jī)名
    hostname: jpaas-eip-server
    # 環(huán)境配置
    environment:
      TZ: Asia/Shanghai
      APPLICTION_OPTS: "-Dspring.profiles.active=prod"
      JAVA_OPTS: "-Xms4096m -Xmx4096m -XX:+UseG1GC -XX:+UseStringDeduplication  -Xloggc:/root/jpaas-gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/root/  -Dfile.encoding=utf-8"
    deploy:
      replicas: 1
      placement:
        # 需要部署服務(wù)器的標(biāo)簽
        constraints: [node.labels.foo == app]
      restart_policy:
        condition: on-failure
    # 暴露外部端口:內(nèi)部端口
    ports:
      - 9900:9900
    networks:
      - golbal-service-jpaas-net
# 使用的網(wǎng)絡(luò)
networks:
  golbal-service-jpaas-net:
       external: true

 啟動(dòng)后檢查是否出錯(cuò)(查看日志)

2、啟動(dòng) 前端 服務(wù)

2.1、手動(dòng)構(gòu)建鏡像

先把 前端應(yīng)用程序打成 dist 包,放到指定目錄(把名稱改成你Dockerfile 里面配置的文件夾名稱)

文件目錄

  • -- eip
  • -- docker
  • -- default.conf (就是 nginx 的配置文件)
  • -- Dockerfile

Dockerfile   

FROM harbor.hkc.cn/jpaas/nginx:1.14.1

MAINTAINER liuli@hkc.cn

RUN   ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone

USER root

WORKDIR /

#導(dǎo)入編譯后的dist
COPY  eip/   /usr/share/nginx/html/eip/
ADD  docker/default.conf  /etc/nginx/nginx.conf

#暴露端口
EXPOSE 80 5001 5005 8005

#啟動(dòng)命令
ENTRYPOINT ["nginx","-g","daemon off;"]

docker/default.conf (nginx 的配置文件)

user  root;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/access.log ;
    #error_log  /var/log/error.log ;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;
    server_tokens off;
    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 3;
    gzip_types text/plain application/javascript application/css  text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/jpg;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";
    client_max_body_size 1000m;
    proxy_connect_timeout 300s;
    proxy_send_timeout 300s;
    proxy_read_timeout 300s;

    resolver 127.0.0.11 valid=10s;

    # 直接走請(qǐng)求 ap
    upstream job {
        server jpaas-eip-job-server:9900;
    }
    # 直接走請(qǐng)求 ap
    upstream gateway {
        server jpaas-eip-server:9900;
    }
    # pc 端 后臺(tái)界面  ng
    upstream jpaas {
        server jpaas-jpaas-nginx-server:8000;
    }
    # pc 端 表單界面  ng
    upstream form {
        server jpaas-form-nginx-server:8000;
    }

    # eip pc 服務(wù)
    server {

       listen       80;
       server_name  localhost;

       location /jpaas {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://jpaas;
       }

       location /job {
          proxy_set_header Host       $host;
          proxy_pass http://job;
       }

        location / {
            root   html;
            index  index.html index.htm;
        }

       location /eip {
           alias  /usr/share/nginx/html/eip/;
           index  index.html index.htm;
           try_files $uri $uri/ /eip/index.html;
           client_max_body_size 900m;
           client_body_buffer_size 900m;
       }

       location /form {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://form;
       }

       location /api/ {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header developer ray;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://gateway/;
       }

      location /api/srm {
        proxy_set_header Host       $host;
        proxy_pass http://172.16.11.56:2381/;
        client_max_body_size 50m;
        client_body_buffer_size 50m;
        rewrite "^/api/(.*)$" /$1 break;
      }

      location /api/DccProcess/Incomplete.do {
          #proxy_set_header Host       $host;
          #proxy_pass http://10.5.0.75:8150/api/DccProcess/Incomplete.do;
          #client_max_body_size 50m;
          #client_body_buffer_size 50m;
          proxy_set_header Host       $host;
          proxy_pass http://localhost:8002/;
          rewrite ^/api/DccProcess/(.*)$ /api/dcc-process/$1 last; # 使用last進(jìn)行內(nèi)部重定向
        }
        location /api/dcc-process {
              proxy_set_header Host       $host;
              proxy_pass http://10.5.0.75:8150/;
              client_max_body_size 50m;
              client_body_buffer_size 50m;
              # rewrite "^/api/(.*)$" /$1 break;
              rewrite ^/api/dcc-process/(.*)$ /api/DccProcess/$1 break;
        }
        location /api/ecs {
            proxy_set_header Host       $host;
            proxy_set_header ORigin     "";
            proxy_pass http://10.5.101.138:14114/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/ecs/(.*)$" /$1 break;
        }
          location /api/oa3 {
            proxy_set_header Host       $host;
            proxy_set_header ORigin     "";
            proxy_pass http://10.5.101.138:14114/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/oa3/(.*)$" /$1 break;
        }
        location /api/hkc {
            proxy_set_header Host       $host;
            proxy_pass http://172.16.0.212:8090/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/qspsams {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.225/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/goal {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.100.67:7207/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/ehr {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.199:8089/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/ehr/(.*)$" /$1 break;
        }
        location /api/pzdqh {
            proxy_set_header Host       $host;
            proxy_pass http://pz.cqhkc.com:9999/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/pzdqh/(.*)$" /$1 break;
        }
        location /api/pzdsh {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.183:8080/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/pzdsh/(.*)$" /$1 break;
        }
    }
    # 文件服務(wù)端口 5001
    server {
        listen       5001;
        server_name  localhost;

        location / {
            root   /root/serverfiles/opt/temp111;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }
    }
    # 文件服務(wù)端口 5005
    server {
        listen       5005;
        server_name  localhost;

        location / {
            root   /root/serverfiles/historyfile;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }
    }
    # 文件服務(wù)端口 8005
    server {
        listen       8005;
        server_name  localhost;

        location / {
            root   /root/serverfiles/upload;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }
    }
}

執(zhí)行構(gòu)建命令

# 把jar包和Dockerfile 放在同一層目錄
docker build -t harbor.hkc.cn/eip/jpass-eip-web:v1 .

# 先登錄到鏡像服務(wù)器  登錄遠(yuǎn)程
docker login harbor.hkc.cn

# 推送鏡像  docker push 鏡像名:標(biāo)簽名
docker push harbor.hkc.cn/eip/jpaas-eip-web:v1

# 鏡像倉庫地址:查看是否推送
https://xxxx.xxxx.xxxx.xxxx/harbor/

2.2、gitlab 流水線構(gòu)建鏡像

Dockerfile   

FROM harbor.hkc.cn/jpaas/nginx:1.14.1

MAINTAINER liuli@hkc.cn

RUN   ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone

USER root

WORKDIR /

#導(dǎo)入編譯后的dist
COPY  eip/   /usr/share/nginx/html/eip/
# 這個(gè)可能路徑隨著具體能訪問的路徑變化
ADD  jpaas-admin-front/docker/default.conf  /etc/nginx/nginx.conf

#暴露端口
EXPOSE 80 5001 5005 8005

#啟動(dòng)命令
ENTRYPOINT ["nginx","-g","daemon off;"]

docker/default.conf (nginx 的配置文件)

user  root;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/access.log ;
    #error_log  /var/log/error.log ;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;
    server_tokens off;
    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 3;
    gzip_types text/plain application/javascript application/css  text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/jpg;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";
    client_max_body_size 1000m;
    proxy_connect_timeout 300s;
    proxy_send_timeout 300s;
    proxy_read_timeout 300s;

    resolver 127.0.0.11 valid=10s;

    # 直接走請(qǐng)求 ap
    upstream job {
        server jpaas-eip-job-server:9900;
    }
    # 直接走請(qǐng)求 ap
    upstream gateway {
        server jpaas-eip-server:9900;
    }
    # pc 端 后臺(tái)界面  ng
    upstream jpaas {
        server jpaas-jpaas-nginx-server:8000;
    }
    # pc 端 表單界面  ng
    upstream form {
        server jpaas-form-nginx-server:8000;
    }

    # eip pc 服務(wù)
    server {

       listen       80;
       server_name  localhost;

       location /jpaas {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://jpaas;
       }

       location /job {
          proxy_set_header Host       $host;
          proxy_pass http://job;
       }

        location / {
            root   html;
            index  index.html index.htm;
        }

       location /eip {
           alias  /usr/share/nginx/html/eip/;
           index  index.html index.htm;
           try_files $uri $uri/ /eip/index.html;
           client_max_body_size 900m;
           client_body_buffer_size 900m;
       }

       location /form {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://form;
       }

       location /api/ {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header developer ray;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://gateway/;
       }

      location /api/srm {
        proxy_set_header Host       $host;
        proxy_pass http://172.16.11.56:2381/;
        client_max_body_size 50m;
        client_body_buffer_size 50m;
        rewrite "^/api/(.*)$" /$1 break;
      }

      location /api/DccProcess/Incomplete.do {
          #proxy_set_header Host       $host;
          #proxy_pass http://10.5.0.75:8150/api/DccProcess/Incomplete.do;
          #client_max_body_size 50m;
          #client_body_buffer_size 50m;
          proxy_set_header Host       $host;
          proxy_pass http://localhost:8002/;
          rewrite ^/api/DccProcess/(.*)$ /api/dcc-process/$1 last; # 使用last進(jìn)行內(nèi)部重定向
        }
        location /api/dcc-process {
              proxy_set_header Host       $host;
              proxy_pass http://10.5.0.75:8150/;
              client_max_body_size 50m;
              client_body_buffer_size 50m;
              # rewrite "^/api/(.*)$" /$1 break;
              rewrite ^/api/dcc-process/(.*)$ /api/DccProcess/$1 break;
        }
        location /api/ecs {
            proxy_set_header Host       $host;
            proxy_set_header ORigin     "";
            proxy_pass http://10.5.101.138:14114/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/ecs/(.*)$" /$1 break;
        }
          location /api/oa3 {
            proxy_set_header Host       $host;
            proxy_set_header ORigin     "";
            proxy_pass http://10.5.101.138:14114/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/oa3/(.*)$" /$1 break;
        }
        location /api/hkc {
            proxy_set_header Host       $host;
            proxy_pass http://172.16.0.212:8090/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/qspsams {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.225/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/goal {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.100.67:7207/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/ehr {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.199:8089/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/ehr/(.*)$" /$1 break;
        }
        location /api/pzdqh {
            proxy_set_header Host       $host;
            proxy_pass http://pz.cqhkc.com:9999/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/pzdqh/(.*)$" /$1 break;
        }
        location /api/pzdsh {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.183:8080/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/pzdsh/(.*)$" /$1 break;
        }
    }
    # 文件服務(wù)端口 5001
    server {
        listen       5001;
        server_name  localhost;

        location / {
            root   /root/serverfiles/opt/temp111;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }
    }
    # 文件服務(wù)端口 5005
    server {
        listen       5005;
        server_name  localhost;

        location / {
            root   /root/serverfiles/historyfile;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }
    }
    # 文件服務(wù)端口 8005
    server {
        listen       8005;
        server_name  localhost;

        location / {
            root   /root/serverfiles/upload;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }
    }
}

.gitlab-ci.yml 文件

image: harbor.hkc.cn/jpaas/node:16.20.0-alpine

stages:
    - maven
    - deploy

# 當(dāng)前路徑均為 .gitlab-ci.yml文件所在目錄
npm_job:
    stage: maven
    tags:
        - default
    # 指定分支
    only:
        - eip_release_git
        #- eip_release
        #- eip_test
        #- eip_dev
    script:
        - echo "maven job maven version"
        - mkdir -p /root/gitrunner/$CI_PROJECT_NAME
        #- npm install --registry=http://10.5.100.108:18081/repository/npm-hkc-public/
        # 注意具體項(xiàng)目文件路徑 需要?jiǎng)討B(tài)修改  node_modules  是放在服務(wù)器上的能訪問的依賴文件
        - cp -rf  /root/gitrunner/eip_pc_module/node_modules ./jpaas-admin-front/
        - cd jpaas-admin-front
        # 如果 build 失敗,需要對(duì) vue-cli-service 進(jìn)行授權(quán)
        #- chmod 777 node_modules/.bin/vue-cli-service
        - npm run build:prod
        - mv dist eip
        - tar -zcvf eip.tar.gz eip
        - cp -rf eip.tar.gz /root/gitrunner/$CI_PROJECT_NAME/
    cache:
        paths:
            - node_modules
    # artifacts:
    #   expire_in: 3 hrs
    #   paths:
    #     - ./target/hkc-eip.jar

deploy_job:
    stage: deploy
    image: docker:stable
    variables:
        DOCKER_TLS_CERTDIR: ""
        GODEBUG: "x509ignoreCN=0"
        DOCKER_HOST: "tcp://docker:2375"
    services:
        - name: docker:19.03.8-dind
          alias: docker
          command:
              - "--insecure-registry=harbor.hkc.cn"
    tags:
        - default
    # 指定分支
    only:
        - eip_release_git
        #- eip_release
        #- eip_test
        #- eip_dev
    script:
        - datetime=`date +%Y%m%d%H%M%S`
        - echo "set now datetime"
        - echo $datetime
        # - ls -al
        - echo "set branch name CI_PROJECT_NAME"
        - echo $CI_PROJECT_NAME
        # - ls -al /root/gitrunner/$CI_PROJECT_NAME
        - cp -rf /root/gitrunner/$CI_PROJECT_NAME/eip.tar.gz  . && tar -zxvf eip.tar.gz && rm -rf eip.tar.gz
        - docker login harbor.hkc.cn -u 0179733 -p Qweasd123
        # 注意 Dockerfile 和 nginx 的配置文件的位置
        - docker build -t harbor.hkc.cn/eip/jpaas-eip-web:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA-$datetime -f ./jpaas-admin-front/Dockerfile .
        - docker push harbor.hkc.cn/eip/jpaas-eip-web:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA-$datetime
    after_script:
        - rm -rf /root/gitrunner/$CI_PROJECT_NAME

啟動(dòng)服務(wù):

在 portainer ce 上配置堆棧啟動(dòng)

去 鏡像倉庫找到最新的鏡像文件

jpaas-eip-nginx-server.yml 啟動(dòng)文件信息

version: '3.7'
services:
  jpaas-eip-nginx-server:
    # 鏡像名
    image: harbor.hkc.cn/eip/jpaas-eip-web:eip_release_git-ebb79d2d-20240429075512
    # 容器名
    container_name: jpaas-eip-nginx-server
    # 主機(jī)名
    hostname: jpaas-eip-nginx-server
    # 環(huán)境配置
    environment:
      - TZ=Asia/Shanghai
    volumes:
      - /root/serverfiles/opt/temp111:/root/serverfiles/opt/temp111
      - /root/serverfiles/historyfile:/root/serverfiles/historyfile
      - /root/serverfiles/upload:/root/serverfiles/upload
    # 開放端口
    ports:
      - 80:80
      - 5001:5001
      - 5005:5005
      - 8005:8005
    privileged: true
    deploy:
      replicas: 1
      placement:
        # 需要部署服務(wù)器的標(biāo)簽
        constraints: [node.labels.foo == manager]
      restart_policy:
        condition: on-failure
    networks:
      - golbal-service-jpaas-net
# 使用的網(wǎng)絡(luò)
networks:
  golbal-service-jpaas-net:
       external: true

啟動(dòng)后檢查是否出錯(cuò)(查看日志)

3、啟動(dòng) nginx 做代理

3.1、直接堆棧啟動(dòng)

eip_nginx.yml

version: '3.7'
configs:
   # 定義配置文件
   nginx-config:
     external: true
     name: nginx-config.conf
services:
  nginx:
    # 鏡像名稱
    image: harbor.hkc.cn/jpaas/nginx:1.14.1
    # 主機(jī)名
    hostname: jpaas-top-proxy-nginx-server
    # 容器名
    container_name: jpaas-top-proxy-nginx-server
    environment:
      - TZ=Asia/Shanghai
    # 掛在數(shù)據(jù)目錄
    volumes:
      - /root/serverfiles/opt/temp111:/root/serverfiles/opt/temp111
      - /root/serverfiles/historyfile:/root/serverfiles/historyfile
      - /root/serverfiles/upload:/root/serverfiles/upload
    # 開放端口
    ports:
      - 80:80
      - 5001:5001
      - 5005:5005
      - 8005:8005
    configs:
      - source: nginx-config
        target: /etc/nginx/nginx.conf
    deploy:
      replicas: 1
      placement:
        # 需要部署服務(wù)器的標(biāo)簽
        constraints: [node.labels.foo == manager]
      restart_policy:
        condition: on-failure
    privileged: true
    restart: always
    # 使用網(wǎng)絡(luò)
    networks:
      - golbal-service-jpaas-net

# 定義網(wǎng)絡(luò)
networks:
  golbal-service-jpaas-net:
       external: true

需要 新增配置文件

nginx-config.yml

user  root;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/access.log ;
    #error_log  /var/log/error.log ;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;
    server_tokens off;
    gzip  on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 3;
    gzip_types text/plain application/javascript application/css  text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/jpg;
    gzip_vary off;
    gzip_disable "MSIE [1-6]\.";
    client_max_body_size 1000m;
    proxy_connect_timeout 300s;
    proxy_send_timeout 300s;
    proxy_read_timeout 300s;

    resolver 127.0.0.11 valid=10s;
    
    # 直接走請(qǐng)求 ap 
    upstream job {
        server jpaas-eip-job-server:9900;
    }
    # 直接走請(qǐng)求 ap 
    upstream gateway {
        server jpaas-eip-server:9900;
    }
    # pc 端 界面  ng
    upstream eip {
        server jpaas-eip-nginx-server:8000;
    }
    # pc 端 界面  ng
    upstream eipmobile {
        server jpaas-eip-mobile-nginx-server:8000;
    }
    # pc 端 后臺(tái)界面  ng
    upstream jpaas {
        server jpaas-jpaas-nginx-server:8000;
    }
    # pc 端 表單界面  ng
    upstream form {
        server jpaas-form-nginx-server:8000;
    }

    # eip pc 服務(wù)
    server {

       listen       80;
       server_name  localhost;
       
       location /jpaas {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://jpaas;
       }
       
       location /job {
          proxy_set_header Host       $host;
          proxy_pass http://job;
       }
       
       location /eip {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://eip;
       }
       
       location /form {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://form;
       }

       location /api/ {
          client_max_body_size 1000m;
          proxy_connect_timeout 300s;
          proxy_send_timeout 300s;
          proxy_read_timeout 300s;
          proxy_set_header developer ray;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://gateway/;
       }
       
      location /api/srm {
        proxy_set_header Host       $host;
        proxy_pass http://172.16.11.56:2381/;
        client_max_body_size 50m;
        client_body_buffer_size 50m;
        rewrite "^/api/(.*)$" /$1 break;
      }
       
      location /api/DccProcess/Incomplete.do {
          #proxy_set_header Host       $host;
          #proxy_pass http://10.5.0.75:8150/api/DccProcess/Incomplete.do;
          #client_max_body_size 50m;
          #client_body_buffer_size 50m;
          proxy_set_header Host       $host;
          proxy_pass http://localhost:8002/;
          rewrite ^/api/DccProcess/(.*)$ /api/dcc-process/$1 last; # 使用last進(jìn)行內(nèi)部重定向
        }
        location /api/dcc-process {
              proxy_set_header Host       $host;
              proxy_pass http://10.5.0.75:8150/;
              client_max_body_size 50m;
              client_body_buffer_size 50m;
              # rewrite "^/api/(.*)$" /$1 break;
              rewrite ^/api/dcc-process/(.*)$ /api/DccProcess/$1 break;
        }
        location /api/ecs {
            proxy_set_header Host       $host;
            proxy_set_header ORigin     "";
            proxy_pass http://10.5.101.138:14114/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/ecs/(.*)$" /$1 break;
        }
          location /api/oa3 {
            proxy_set_header Host       $host;
            proxy_set_header ORigin     "";
            proxy_pass http://10.5.101.138:14114/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/oa3/(.*)$" /$1 break;
        }
        location /api/hkc {
            proxy_set_header Host       $host;
            proxy_pass http://172.16.0.212:8090/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/qspsams {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.225/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/goal {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.100.67:7207/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/(.*)$" /$1 break;
        }
        location /api/ehr {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.199:8089/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/ehr/(.*)$" /$1 break;
        }
        location /api/pzdqh {
            proxy_set_header Host       $host;
            proxy_pass http://pz.cqhkc.com:9999/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/pzdqh/(.*)$" /$1 break;
        }
        location /api/pzdsh {
            proxy_set_header Host       $host;
            proxy_pass http://10.5.0.183:8080/;
            client_max_body_size 50m;
            client_body_buffer_size 50m;
            rewrite "^/api/pzdsh/(.*)$" /$1 break;
        }
    }
    # 文件服務(wù)端口 5001
    server {
        listen       5001;
        server_name  localhost;

        location / {
            root   /root/serverfiles/opt/temp111;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }
    }
    # 文件服務(wù)端口 5005
    server {
        listen       5005;
        server_name  localhost;
        
        location / {
            root   /root/serverfiles/historyfile;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }
    }
    # 文件服務(wù)端口 8005
    server {
        listen       8005;
        server_name  localhost;
  
        location / {
            root   /root/serverfiles/upload;
            index  index.html index.htm;
            if ($request_filename ~* .*\.(jpg)$){
                add_header Cache-Control "no-cache, no-store";
            }
        }       
    }
}

在堆棧出查看是否成功

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 詳解docker容器分配靜態(tài)IP

    詳解docker容器分配靜態(tài)IP

    這篇文章主要介紹了詳解docker容器分配靜態(tài)IP,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-01-01
  • Windows/Mac系統(tǒng)Docker方式安裝Mysql(包含utf8)

    Windows/Mac系統(tǒng)Docker方式安裝Mysql(包含utf8)

    本文主要介紹了Windows/Mac系統(tǒng)Docker方式安裝Mysql(包含utf8),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • 替換docker容器中的一個(gè)文件的實(shí)現(xiàn)

    替換docker容器中的一個(gè)文件的實(shí)現(xiàn)

    在某些情況下,我們可能確實(shí)需要更新容器內(nèi)的文件,本文主要介紹了替換docker容器中的一個(gè)文件的實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-06-06
  • 使用Docker快速安裝grafana的基本步驟

    使用Docker快速安裝grafana的基本步驟

    Grafana 是一個(gè)強(qiáng)大的開源監(jiān)控和數(shù)據(jù)分析平臺(tái),它能夠與各種數(shù)據(jù)源集成,并提供靈活的可視化和儀表盤功能,下面給大家分享Docker 中安裝 Grafana 的基本步驟,感興趣的朋友一起看看吧
    2024-01-01
  • 使用Docker容器部署rocketmq單機(jī)的全過程

    使用Docker容器部署rocketmq單機(jī)的全過程

    這篇文章主要介紹了使用Docker容器部署rocketmq單機(jī),詳細(xì)介紹了查詢鏡像拉取鏡像的命令,對(duì)Docker部署rocketmq相關(guān)知識(shí)感興趣的朋友一起看看吧
    2022-04-04
  • docker中容器數(shù)據(jù)卷volume介紹

    docker中容器數(shù)據(jù)卷volume介紹

    大家好,本篇文章主要講的是docker中容器數(shù)據(jù)卷volume介紹,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽
    2021-12-12
  • docker 實(shí)現(xiàn)容器與宿主機(jī)無縫調(diào)用shell命令

    docker 實(shí)現(xiàn)容器與宿主機(jī)無縫調(diào)用shell命令

    這篇文章主要介紹了docker 實(shí)現(xiàn)容器與宿主機(jī)無縫調(diào)用shell命令的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨想過來看看吧
    2021-03-03
  • Docker自定義JDK鏡像并拉取至阿里云鏡像倉庫超詳細(xì)攻略

    Docker自定義JDK鏡像并拉取至阿里云鏡像倉庫超詳細(xì)攻略

    Docker倉庫是集中存放鏡像的地方,分為公共倉庫和私有倉庫,這篇文章主要給大家介紹了關(guān)于Docker自定義JDK鏡像并拉取至阿里云鏡像倉庫的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-08-08
  • Docker安裝配置MySQL的實(shí)現(xiàn)步驟

    Docker安裝配置MySQL的實(shí)現(xiàn)步驟

    MySQL 是最流行的關(guān)系型數(shù)據(jù)庫管理系統(tǒng),在 WEB 應(yīng)用方面 MySQL 是最好的 RDBMS(Relational Database Management System:關(guān)系數(shù)據(jù)庫管理系統(tǒng))應(yīng)用軟件之一。在本教程中,會(huì)帶大家正確安裝配置MySQL在Docker
    2021-11-11
  • 如何在docker中運(yùn)行springboot項(xiàng)目過程圖解

    如何在docker中運(yùn)行springboot項(xiàng)目過程圖解

    這篇文章主要介紹了如何在docker中運(yùn)行springboot項(xiàng)目過程圖解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-06-06

最新評(píng)論