Эх сурвалжийг харах

drone: 更新构建镜像配置

Yi 1 жил өмнө
parent
commit
411aac8030
3 өөрчлөгдсөн 116 нэмэгдсэн , 50 устгасан
  1. 90 5
      .drone.yml
  2. 5 3
      Dockerfile
  3. 21 42
      default.conf.template

+ 90 - 5
.drone.yml

@@ -1,6 +1,6 @@
 kind: pipeline
 type: docker
-name: calf-feed-admin
+name: test
 
 steps:
   - name: build
@@ -20,16 +20,25 @@ steps:
         from_secret: aliyun_password
       repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/calf-feed-admin
       registry: registry.cn-hangzhou.aliyuncs.com
-      tags: [ 1.0.0,latest ]
-
+      tags: [ test ]
+  - name: ssh commands
+    image: appleboy/drone-ssh
+    settings:
+      host: 192.168.1.70
+      username: tmrwatch
+      password:
+        from_secret: ssh_password
+      port: 22
+      script:
+        - cd /data/docker-compose/calf-feed-admin/
+        - echo "123456" | ./restart.sh
 trigger:
   branch:
     include:
-      - develop
+      - feature/*
   event:
     include:
       - push
-
 volumes:
   - name: host
     host:
@@ -37,6 +46,82 @@ volumes:
   - name: docker-ca
     host:
       path: /ect/docker
+  - name: docker-sock
+    host:
+      path: /var/run/docker.sock
+---
+kind: pipeline
+type: docker
+name: product
+steps:
+  - name: build
+    image: plugins/docker:20.14.2
+    volumes:
+      - name: hosts
+        path: /etc/hosts
+      - name: docker-ca
+        path: /etc/docker
+      - name: docker-sock
+        path: /var/run/docker.sock
+    settings:
+      username:
+        from_secret: aliyun_name
+      password:
+        from_secret: aliyun_password
+      repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/calf-feed-admin
+      registry: registry.cn-hangzhou.aliyuncs.com
+      tag:
+        - latest
+        - ${DRONE_BRANCH##release/}
+trigger:
+  branch:
+    include:
+      - release/*
+  event:
+    include:
+      - push
+volumes:
+  - name: docker-ca
+    host:
+      path: /etc/docker
+  - name: docker-sock
+    host:
+      path: /var/run/docker.sock
+---
+kind: pipeline
+type: docker
+name: hotfix
+
+steps:
+  - name: build
+    image: plugins/docker:20.14.2
+    volumes:
+      - name: hosts
+        path: /etc/hosts
+      - name: docker-ca
+        path: /etc/docker
+      - name: docker-sock
+        path: /var/run/docker.sock
+    settings:
+      username:
+        from_secret: aliyun_name
+      password:
+        from_secret: aliyun_password
+      repo: registry.cn-hangzhou.aliyuncs.com/kpt-event/calf-feed-admin
+      registry: registry.cn-hangzhou.aliyuncs.com
+      tag:
+        - latest
+trigger:
+  branch:
+    include:
+      - hotfix/*
+  event:
+    include:
+      - push
+volumes:
+  - name: docker-ca
+    host:
+      path: /etc/docker
   - name: docker-sock
     host:
       path: /var/run/docker.sock

+ 5 - 3
Dockerfile

@@ -10,7 +10,9 @@ RUN npm install
 RUN npm run build
 
 # 第二阶段构建
-FROM nginx:alpine
+FROM nginx:stable-alpine3.17
 COPY --from=builder /app/calf-feed-admin/dist/ /usr/share/nginx/html/
-COPY --from=builder /app/calf-feed-admin/default.conf.template /etc/nginx/templates/default.conf.template
-EXPOSE 80
+COPY --from=builder /app/calf-feed-admin/default.conf.template /etc/nginx/conf.d/default.conf
+EXPOSE 80
+
+CMD ["/bin/sh", "-c", "sed -i \"s@<html@<html domain=\"$DOMAIN\"@\" /usr/share/nginx/html/index.html; nginx -g \"daemon off;\""]

+ 21 - 42
default.conf.template

@@ -1,53 +1,32 @@
 server {
-    listen       80;
-    listen  [::]:80;
-    server_name  localhost;
+   listen       80;
+   listen  [::]:80;
+   server_name  localhost;
 
-    #access_log  /var/log/nginx/host.access.log  main;
+   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 / {
         root /usr/share/nginx/html;
         #index index.html;
         try_files $uri $uri/ /index.html;
+        client_max_body_size 300m;   #最大接受300m文件以内的
+        client_body_timeout 20s;
    }
-    #error_page  404              /404.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;
-    }
-
-    # location /prod-api/ {
-    #    proxy_pass  ${BACKEND_HOST};
-    #    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_http_version 1.1;
-    #    proxy_set_header Connection "";
-    #}
-
-    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
-    #
-    #location ~ \.php$ {
-    #    proxy_pass   http://127.0.0.1;
-    #}
+   location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css){
+       root    /usr/share/nginx/html;
+       expires 7d;
+   }
 
-    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
-    #
-    #location ~ \.php$ {
-    #    root           html;
-    #    fastcgi_pass   127.0.0.1:9000;
-    #    fastcgi_index  index.php;
-    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
-    #    include        fastcgi_params;
-    #}
+   #error_page  404              /404.html;
 
-    # deny access to .htaccess files, if Apache's document root
-    # concurs with nginx's one
-    #
-    #location ~ /\.ht {
-    #    deny  all;
-    #}
-}
+   # 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;
+   }
+}