Browse Source

ci(other): cicd 3

Yi 1 year ago
parent
commit
a372dac5cb
3 changed files with 39 additions and 137 deletions
  1. 14 20
      Dockerfile
  2. 0 70
      docker-compose.yml
  3. 25 47
      nginx.conf

+ 14 - 20
Dockerfile

@@ -1,22 +1,16 @@
-FROM node:16.17.0 as builder
-
-ENV WORKDIR=/kpt-system-web
-
-WORKDIR $WORKDIR
-
-ARG version
-ENV COMMITID=$version
-
-RUN npm i -g pnpm
-
-RUN pnpm install
-RUN pnpm build
-
+FROM node:14.0.0 as builder
+WORKDIR /app/kpt-system-web
+#拷贝源码
+COPY . .
+#安装依赖
+RUN npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
+RUN npm install
+
+# 开始构建
+RUN npm run build
+
+# 第二阶段构建
 FROM nginx:alpine as prod
-
-RUN mkdir /kpt-system-web
-
-COPY --from=builder /kpt-system-web/dist /kpt-system-web
-COPY --from=builder /kpt-system-web/nginx.conf /etc/nginx/nginx.conf
-
+COPY --from=builder /app/kpt-system-web/dist/ /usr/share/nginx/html/
+COPY --from=builder /app/kpt-system-web/default.conf.template /etc/nginx/conf.d/default.conf
 EXPOSE 80

+ 0 - 70
docker-compose.yml

@@ -1,70 +0,0 @@
-version : '3'
-services:
-  kpt-calf-feed-crontab:
-    privileged: true
-    container_name: kpt_calf_feed_crontab
-    restart: always
-    image: registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-calf-feed:test
-    volumes:
-      - /var/logger/calf-feed/:/app/kpt-calf-feed/logger
-      - ./config:/app/kpt-calf-feed/bin/config
-      - /etc/localtime:/etc/localtime
-    environment:
-      - APP_ENVIRONMENT=test
-      - CALF_FEED_WORK_DIR=/app/kpt-calf-feed/bin
-    command: [ "/app/kpt-calf-feed/bin/kptCalfFeed","crontab" ]
-
-  kpt-calf-feed-http:
-    privileged: true
-    container_name: kpt_calf_feed_http
-    restart: always
-    image: registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-calf-feed:test
-    ports:
-      - "8087:8090"
-    volumes:
-      - /var/logger/calf-feed/:/app/kpt-calf-feed/logger
-      - ./config:/app/kpt-calf-feed/bin/config
-      - /etc/localtime:/etc/localtime
-    environment:
-      - APP_ENVIRONMENT=test
-      - CALF_FEED_WORK_DIR=/app/kpt-calf-feed/bin
-    command: ["/app/kpt-calf-feed/bin/kptCalfFeed","http"]
-
-  kpt-calf-feed-consumer:
-    privileged: true
-    container_name: kpt_calf_feed_crontab
-    restart: always
-    image: registry.cn-hangzhou.aliyuncs.com/kpt-event/kpt-calf-feed:test
-    volumes:
-      - /var/logger/calf-feed/:/app/kpt-calf-feed/logger
-      - ./config/:/app/kpt-calf-feed/bin/config/
-      - /etc/localtime:/etc/localtime
-    environment:
-      - APP_ENVIRONMENT=test
-      - CALF_FEED_WORK_DIR=/app/kpt-calf-feed/bin
-    command: ["/app/kpt-calf-feed/bin/kptCalfFeed","consumer"]
-
-  kpt-redis:
-    image: redis:latest
-    restart: "always"
-    container_name: "kpt-redis"
-    ports:
-      - "6389:6379"
-    volumes:
-      - ./redis/redis.conf:/etc/redis/redis.conf
-      - ./redis/data:/data
-      - ./redis/logs:/var/log/redis/redis.log
-    command: redis-server /etc/redis/redis.conf
-    privileged: true
-
-  kpt-asynqmon:
-    image: hibiken/asynqmon:latest
-    container_name: kpt-asynqmon_asynq
-    ports:
-      - 7081:8080
-    command:
-      - '--redis-addr=kpt-redis:6389'
-      - '--redis-db=0'
-    restart: always
-    depends_on:
-      - kpt-redis

+ 25 - 47
nginx.conf

@@ -1,54 +1,32 @@
-user  nginx;
-worker_processes  1;
-error_log  /var/log/nginx/error.log warn;
-pid        /var/run/nginx.pid;
+server {
+   listen       80;
+   listen  [::]:80;
+   server_name  localhost;
 
-events {
-  worker_connections  1024;
-}
-
-http {
-  include       /etc/nginx/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/nginx/access.log  main;
-  sendfile        on;
-  keepalive_timeout  65;
-
-  server {
-    listen       80;
-    server_name  localhost;
+   gzip on;
+   gzip_static on;
+   gzip_comp_level 6;
+   gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
 
-    location / {
-      # 不缓存html,防止程序更新后缓存继续生效
-      if ($request_filename ~* .*\.(?:htm|html)$) {
-        add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
-        access_log on;
-      }
-      root   /soybean-admin/;
-      index  index.html index.htm;
-      try_files $uri $uri/ /index.html;
-    }
+   location / {
+        root /usr/share/nginx/html;
+        #index index.html;
+        try_files $uri $uri/ /index.html;
+        client_max_body_size 300m;   #最大接受300m文件以内的
+        client_body_timeout 20s;
+   }
 
-    # location /soybean/soybean-webserver/v1 {
-    #     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_set_header REMOTE-HOST $remote_addr;
+   location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css){
+       root    /usr/share/nginx/html;
+       expires 7d;
+   }
 
-    #     # 后台接口地址
-    #     proxy_pass http://192.168.1.99:30597/v1;
-    #     proxy_redirect default;
-    #     add_header Access-Control-Allow-Origin *;
-    #     add_header Access-Control-Allow-Headers X-Requested-With;
-    #     add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
-    # }
+   #error_page  404              /404.html;
 
-    error_page   500 502 503 504  /50x.html;
-    location = /50x.html {
+   # redirect server error pages to the static page /50x.html
+   #
+   error_page   500 502 503 504  /50x.html;
+   location = /50x.html {
       root   /usr/share/nginx/html;
-    }
-  }
+   }
 }