diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..c629537 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,32 @@ +kind: pipeline +type: kubernetes + +name: build-and-deploy-prod + +trigger: + event: + - push + branch: + - master + +steps: + - name: prod-build-image + image: ccr.ccs.tencentyun.com/violin/drone-kaniko:latest + settings: + repo: ccr.ccs.tencentyun.com/violin/violin-cv + tags: + - latest + dockerfile: Dockerfile + context: . + registry: ccr.ccs.tencentyun.com + username: 100024540033 + 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/violin-cv cv=ccr.ccs.tencentyun.com/violin/violin-cv:latest + - kubectl rollout status deployment/violin-cv diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3401765 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# ============================================================ +# violin-cv Dockerfile — 纯 HTML 静态站(不 build) +# ============================================================ +# 架构: +# 1. 基础镜像:nginx alpine(轻量) +# 2. COPY:把 src/pages/*.html 直接复制到 nginx serve 目录 +# 3. nginx 配置:让 / 指向 index.html +# +# 注意:HTML 中所有 style / script 都在文件内联(或外部 fonts), +# 所以不依赖额外的 CSS / JS 文件 —— 单文件即可 serve。 +# ============================================================ + +FROM ccr.ccs.tencentyun.com/violin/nginx + +# 删除默认 nginx 配置 +RUN rm /etc/nginx/conf.d/default.conf + +# 复制 nginx 配置 +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# 复制静态文件(含 HTML) +COPY src/pages/ /usr/share/nginx/html/ + +# 暴露 HTTP 端口 +EXPOSE 80 + +# 健康检查(可选,K8s 会用) +HEALTHCHECK --interval=30s --timeout=3s --retries=3 \ + CMD wget -q --spider http://localhost/ || exit 1 + +CMD ["nginx", "-g", "daemon off;"] diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..9ccd878 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,32 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + # 字符集 + gzip + charset utf-8; + gzip on; + gzip_types text/css application/javascript text/javascript application/json + image/svg+xml application/xml text/xml application/xml+rss; + + # 安全 headers + add_header X-Content-Type-Options "nosniff" always; + add_header X-Frame-Options "SAMEORIGIN" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + + # SPA 回退(虽然当前没路由,但留个兜底) + location / { + try_files $uri $uri/ $uri.html /index.html; + } + + # 静态资源缓存(图片 / css / js) + location ~* \.(css|js|jpg|jpeg|png|gif|svg|woff|woff2|ttf|eot)$ { + expires 30d; + add_header Cache-Control "public, max-age=2592000"; + } + + # 错误页 fallback + error_page 404 /index.html; +}