From c4d83d18bb01c0e272631cb79b870fb04f80e392 Mon Sep 17 00:00:00 2001 From: Agent Date: Mon, 23 Mar 2026 13:27:55 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=8F=82=E7=85=A7=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E4=BD=BF=E7=94=A8=20kaniko=20?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=EF=BC=8C=E6=B7=BB=E5=8A=A0=20k8s=20=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 72 ++++++++++++++++++--------------------------- Dockerfile | 7 +++++ k8s/deployment.yaml | 37 +++++++++++++++++++++++ 3 files changed, 72 insertions(+), 44 deletions(-) create mode 100644 Dockerfile create mode 100644 k8s/deployment.yaml diff --git a/.drone.yml b/.drone.yml index 4f0490d..28b69d6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,9 +1,10 @@ kind: pipeline type: kubernetes -clone: - disable: true + name: build-and-deploy-dev +service_account_name: drone-builder-sa + trigger: event: - push @@ -11,50 +12,41 @@ trigger: - dev steps: - - name: dev-clone - image: ccr.ccs.tencentyun.com/violin/git-alpine:latest - settings: - username: - from_secret: git_username - password: - from_secret: git_password - - name: dev-install - image: node:18-alpine + image: ccr.ccs.tencentyun.com/violin/node:18-alpine commands: - npm install - name: dev-build - image: node:18-alpine + image: ccr.ccs.tencentyun.com/violin/node:18-alpine commands: - npm run build:h5 - name: dev-build-image - image: ccr.ccs.tencentyun.com/violin/docker:linux-amd64 + image: ccr.ccs.tencentyun.com/violin/drone-kaniko:latest settings: repo: ccr.ccs.tencentyun.com/violin/todo-frontend tags: - - ${DRONE_COMMIT_SHA} - latest - username: - from_secret: registry_username + - ${DRONE_COMMIT_SHA:0:8} + dockerfile: Dockerfile + context: . + registry: ccr.ccs.tencentyun.com + username: 100024540033 password: - from_secret: registry_password + from_secret: docker_password - name: dev-deploy image: ccr.ccs.tencentyun.com/violin/kubectl:latest + cluster: kubernetes + namespace: drone commands: - - kubectl set image deployment/todo-frontend todo-frontend=ccr.ccs.tencentyun.com/violin/todo-frontend:${DRONE_COMMIT_SHA} -n drone - - kubectl rollout status deployment/todo-frontend -n drone - environment: - KUBECONFIG: - from_secret: kubeconfig + - kubectl apply -f k8s/deployment.yaml --- kind: pipeline type: kubernetes -clone: - disable: true + name: build-and-deploy-prod trigger: @@ -64,41 +56,33 @@ trigger: - master steps: - - name: prod-clone - image: ccr.ccs.tencentyun.com/violin/git-alpine:latest - settings: - username: - from_secret: git_username - password: - from_secret: git_password - - name: prod-install - image: node:18-alpine + image: ccr.ccs.tencentyun.com/violin/node:18-alpine commands: - npm install - name: prod-build - image: node:18-alpine + image: ccr.ccs.tencentyun.com/violin/node:18-alpine commands: - npm run build:h5 - name: prod-build-image - image: ccr.ccs.tencentyun.com/violin/docker:linux-amd64 + image: ccr.ccs.tencentyun.com/violin/drone-kaniko:latest settings: repo: ccr.ccs.tencentyun.com/violin/todo-frontend tags: - - ${DRONE_COMMIT_SHA} - v1.0.0 - username: - from_secret: registry_username + dockerfile: Dockerfile + context: . + registry: ccr.ccs.tencentyun.com + username: 100024540033 password: - from_secret: registry_password + from_secret: docker_password - name: prod-deploy image: ccr.ccs.tencentyun.com/violin/kubectl:latest + cluster: kubernetes + namespace: drone commands: - - kubectl set image deployment/todo-frontend todo-frontend=ccr.ccs.tencentyun.com/violin/todo-frontend:${DRONE_COMMIT_SHA} -n drone - - kubectl rollout status deployment/todo-frontend -n drone - environment: - KUBECONFIG: - from_secret: kubeconfig + - kubectl set image deployment/todo-frontend todo-frontend=ccr.ccs.tencentyun.com/violin/todo-frontend:v1.0.0 + - kubectl rollout status deployment/todo-frontend diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fb19e9c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM ccr.ccs.tencentyun.com/violin/nginx:alpine + +COPY dist/build/h5 /usr/share/nginx/html + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 0000000..46d7180 --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,37 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: todo-frontend + namespace: drone + labels: + app: todo-frontend +spec: + replicas: 1 + selector: + matchLabels: + app: todo-frontend + template: + metadata: + labels: + app: todo-frontend + spec: + imagePullSecrets: + - name: tencentyun-secret + containers: + - name: todo-frontend + image: ccr.ccs.tencentyun.com/violin/todo-frontend:latest + ports: + - containerPort: 80 +--- +apiVersion: v1 +kind: Service +metadata: + name: todo-frontend + namespace: drone +spec: + selector: + app: todo-frontend + ports: + - port: 80 + targetPort: 80 + type: ClusterIP