AIri项目容器化部署深度解析从单机到云原生完整实战【免费下载链接】airi Self hosted, you-owned Grok Companion, a container of souls of waifu, cyber livings to bring them into our worlds, wishing to achieve Neuro-samas altitude. Capable of realtime voice chat, Minecraft, Factorio playing. Web / macOS / Windows supported.项目地址: https://gitcode.com/GitHub_Trending/ai/airiAIri是一个基于大型语言模型的虚拟AI角色项目旨在创建可与用户互动、玩游戏、聊天的数字伴侣。在当今云原生应用大行其道的时代容器化部署已成为现代应用交付的标准实践。本文将深入探讨AIri项目的容器化部署方案涵盖从基础Docker部署到生产级Kubernetes集群的完整实践路径为开发者提供从入门到进阶的云原生应用部署指南。项目架构与容器化价值AIri项目采用微服务架构设计包含前端Web应用、后端API服务、数据库、缓存以及可观测性组件等多个模块。容器化部署为AIri带来了显著优势环境一致性确保开发、测试、生产环境完全一致快速部署通过镜像实现秒级部署和回滚资源隔离避免依赖冲突提高系统稳定性弹性伸缩基于容器编排实现自动扩缩容简化运维统一部署和管理接口基础容器化部署方案Docker单机部署实践AIri项目已提供完整的Dockerfile配置位于apps/stage-web/Dockerfile采用多阶段构建优化镜像大小# 构建阶段 FROM node:24-trixie AS build-stage WORKDIR /app COPY . . RUN pnpm install --frozen-lockfile RUN pnpm -F proj-airi/stage-web run build # 生产阶段 FROM nginx:stable-alpine AS production-stage COPY --frombuild-stage /app/apps/stage-web/dist /usr/share/nginx/html EXPOSE 80 CMD [nginx, -g, daemon off;]执行以下命令即可完成基础部署# 克隆项目仓库 git clone https://gitcode.com/GitHub_Trending/ai/airi cd airi # 构建Docker镜像 docker build -t airi-web -f apps/stage-web/Dockerfile . # 运行容器 docker run -d -p 8080:80 --name airi-web-container airi-web完整服务栈部署对于完整的AIri服务栈项目提供了docker-compose配置位于apps/server/docker-compose.ymlservices: db: image: ghcr.io/tensorchord/vchord-postgres:pg18-v1.0.0 environment: - POSTGRES_DBpostgres - POSTGRES_USERpostgres - POSTGRES_PASSWORDexample-PAssw0rd-xHjDYR.b7N ports: - 5435:5432 volumes: - ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql - db_data:/var/lib/postgresql healthcheck: test: [CMD-SHELL, pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB] redis: image: redis:7-alpine ports: - 6379:6379 volumes: - redis_data:/data healthcheck: test: [CMD, redis-cli, ping] api: build: context: ../.. dockerfile: apps/server/Dockerfile command: [pnpm, -F, proj-airi/server, run, server, api] depends_on: db: condition: service_healthy redis: condition: service_healthy ports: - 6112:3000 healthcheck: test: [CMD-SHELL, curl -f http://localhost:3000/livez || exit 1]启动完整服务栈cd apps/server docker-compose up -d生产环境配置优化环境变量管理AIri支持通过环境变量进行灵活配置建议使用.env文件管理敏感信息# .env.production API_KEYyour_production_api_key DATABASE_URLpostgresql://user:passworddb:5432/airi REDIS_URLredis://redis:6379 NODE_ENVproduction LOG_LEVELinfo资源限制与健康检查为生产环境配置合理的资源限制和健康检查策略# docker-compose.prod.yml services: api: deploy: resources: limits: cpus: 2 memory: 2G reservations: cpus: 0.5 memory: 512M healthcheck: test: [CMD, curl, -f, http://localhost:3000/health] interval: 30s timeout: 10s retries: 3 start_period: 40s logging: driver: json-file options: max-size: 10m max-file: 3网络配置优化配置适当的网络策略确保服务安全networks: airi-network: driver: bridge ipam: config: - subnet: 172.20.0.0/16 services: api: networks: - airi-network ports: - target: 3000 published: 6112 protocol: tcp mode: hostKubernetes集群部署方案Deployment配置创建Kubernetes Deployment资源确保高可用性apiVersion: apps/v1 kind: Deployment metadata: name: airi-api labels: app: airi component: api spec: replicas: 3 strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0 selector: matchLabels: app: airi component: api template: metadata: labels: app: airi component: api spec: securityContext: runAsNonRoot: true runAsUser: 1000 fsGroup: 2000 containers: - name: api image: airi-api:latest imagePullPolicy: IfNotPresent ports: - containerPort: 3000 name: http env: - name: DATABASE_URL valueFrom: secretKeyRef: name: airi-secrets key: database-url - name: REDIS_URL valueFrom: configMapKeyRef: name: airi-config key: redis-url resources: requests: memory: 512Mi cpu: 250m limits: memory: 1Gi cpu: 500m livenessProbe: httpGet: path: /health port: 3000 initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: httpGet: path: /ready port: 3000 initialDelaySeconds: 5 periodSeconds: 5Service与Ingress配置配置服务发现和外部访问apiVersion: v1 kind: Service metadata: name: airi-service spec: selector: app: airi ports: - name: http port: 80 targetPort: 3000 type: ClusterIP --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: airi-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/ssl-redirect: true cert-manager.io/cluster-issuer: letsencrypt-prod spec: tls: - hosts: - airi.example.com secretName: airi-tls rules: - host: airi.example.com http: paths: - path: / pathType: Prefix backend: service: name: airi-service port: number: 80可观测性集成AIri项目已集成OpenTelemetry可通过以下配置启用完整的可观测性栈# apps/server/docker-compose.otel.yml 中的配置 services: otel-collector: image: otel/opentelemetry-collector-contrib:0.120.0 command: [--config/etc/otelcol/otel-collector.yaml] ports: - 4317:4317 # OTLP gRPC - 4318:4318 # OTLP HTTP prometheus: image: prom/prometheus:v3.2.1 volumes: - ./otel/prometheus/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro loki: image: grafana/loki:3.4.3 command: -config.file/etc/loki/loki.yaml tempo: image: grafana/tempo:2.7.2 command: [-config.file/etc/tempo/tempo.yaml] grafana: image: grafana/grafana:11.5.2 environment: - GF_SECURITY_ADMIN_USERadmin - GF_SECURITY_ADMIN_PASSWORDadmin ports: - 3001:3000高级部署策略蓝绿部署与金丝雀发布实现零停机部署策略apiVersion: flagger.app/v1beta1 kind: Canary metadata: name: airi-api spec: targetRef: apiVersion: apps/v1 kind: Deployment name: airi-api service: port: 3000 targetPort: 3000 analysis: interval: 1m threshold: 5 maxWeight: 50 stepWeight: 10 metrics: - name: request-success-rate threshold: 99 interval: 1m - name: request-duration threshold: 500 interval: 1m自动扩缩容配置基于资源使用率自动调整副本数量apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: airi-api-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: airi-api minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70 - type: Resource resource: name: memory target: type: Utilization averageUtilization: 80持久化存储配置配置持久化存储确保数据安全apiVersion: v1 kind: PersistentVolumeClaim metadata: name: airi-postgres-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: standard --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: airi-redis-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi storageClassName: standard安全加固实践安全上下文配置实施最小权限原则securityContext: runAsNonRoot: true runAsUser: 1000 allowPrivilegeEscalation: false capabilities: drop: - ALL readOnlyRootFilesystem: true seccompProfile: type: RuntimeDefault网络策略实施限制Pod间网络通信apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: airi-network-policy spec: podSelector: matchLabels: app: airi policyTypes: - Ingress - Egress ingress: - from: - podSelector: matchLabels: role: frontend ports: - protocol: TCP port: 3000 egress: - to: - podSelector: matchLabels: component: database ports: - protocol: TCP port: 5432密钥管理最佳实践使用Kubernetes Secret管理敏感信息# 创建加密Secret kubectl create secret generic airi-secrets \ --from-literalapi-key$(echo -n your-api-key | base64) \ --from-literaldatabase-password$(echo -n secure-password | base64) \ --from-filessl-certificate./cert.pem \ --from-filessl-key./key.pem # 使用外部Secret存储 kubectl create secret generic airi-external-secrets \ --from-literalvault-addrhttps://vault.example.com \ --from-literalvault-token$(cat /path/to/token)监控与告警配置Prometheus监控规则定义关键业务指标监控groups: - name: airi.rules rules: - alert: HighErrorRate expr: | rate(http_requests_total{status~5..}[5m]) / rate(http_requests_total[5m]) 0.05 for: 5m labels: severity: warning annotations: summary: High error rate detected description: Error rate is {{ $value }} for service {{ $labels.service }} - alert: HighLatency expr: | histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])) 1 for: 5m labels: severity: warning annotations: summary: High latency detected description: 95th percentile latency is {{ $value }}s for service {{ $labels.service }}Grafana仪表板配置创建业务监控仪表板{ dashboard: { title: AIri Service Dashboard, panels: [ { title: Request Rate, targets: [{ expr: rate(http_requests_total[5m]), legendFormat: {{method}} {{status}} }] }, { title: Error Rate, targets: [{ expr: rate(http_requests_total{status~\5..\}[5m]) / rate(http_requests_total[5m]), legendFormat: Error Rate }] }, { title: Response Time, targets: [{ expr: histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])), legendFormat: 95th Percentile }] } ] } }持续集成与部署流水线GitHub Actions自动化部署配置完整的CI/CD流水线name: Deploy AIri to Production on: push: branches: [ main ] pull_request: branches: [ main ] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkoutv4 - name: Setup Node.js uses: actions/setup-nodev4 with: node-version: 20 - name: Install pnpm uses: pnpm/action-setupv2 with: version: 8 - name: Install dependencies run: pnpm install --frozen-lockfile - name: Run tests run: pnpm test build-and-push: needs: test runs-on: ubuntu-latest steps: - uses: actions/checkoutv4 - name: Set up Docker Buildx uses: docker/setup-buildx-actionv3 - name: Log in to Docker Hub uses: docker/login-actionv3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push Docker image uses: docker/build-push-actionv5 with: context: . file: ./apps/stage-web/Dockerfile push: true tags: | ${{ secrets.DOCKER_USERNAME }}/airi-web:latest ${{ secrets.DOCKER_USERNAME }}/airi-web:${{ github.sha }} deploy: needs: build-and-push runs-on: ubuntu-latest steps: - name: Deploy to Kubernetes uses: azure/k8s-deployv4 with: namespace: production manifests: | k8s/deployment.yaml k8s/service.yaml k8s/ingress.yaml images: | ${{ secrets.DOCKER_USERNAME }}/airi-web:${{ github.sha }}故障排除与优化建议常见部署问题解决镜像构建失败检查Dockerfile语法和依赖版本验证构建上下文文件完整性检查网络代理配置容器启动失败查看容器日志docker logs container-id检查环境变量配置验证端口冲突和资源限制服务连接问题检查网络策略和防火墙规则验证服务发现配置检查健康检查端点性能优化建议镜像优化使用多阶段构建减少镜像大小合理利用构建缓存移除不必要的依赖和文件资源配置根据监控数据调整资源限制设置合理的副本数量配置垂直和水平自动扩缩容网络优化使用服务网格进行流量管理配置合适的负载均衡策略优化DNS解析配置总结AIri项目的容器化部署方案展示了现代云原生应用的最佳实践。通过本文介绍的部署策略开发者可以快速搭建开发环境进行本地测试构建生产就绪的Docker镜像部署到Kubernetes集群实现高可用配置完整的可观测性栈进行监控实施安全加固和自动化部署随着AIri项目的持续发展容器化部署将为项目带来更好的可维护性、可扩展性和可靠性。建议开发者根据实际业务需求结合本文提供的配置模板制定适合自身环境的部署方案。通过采用这些容器化部署实践AIri项目能够在各种云环境和本地基础设施中稳定运行为用户提供高质量的虚拟AI角色体验。【免费下载链接】airi Self hosted, you-owned Grok Companion, a container of souls of waifu, cyber livings to bring them into our worlds, wishing to achieve Neuro-samas altitude. Capable of realtime voice chat, Minecraft, Factorio playing. Web / macOS / Windows supported.项目地址: https://gitcode.com/GitHub_Trending/ai/airi创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
AIri项目容器化部署深度解析:从单机到云原生完整实战
AIri项目容器化部署深度解析从单机到云原生完整实战【免费下载链接】airi Self hosted, you-owned Grok Companion, a container of souls of waifu, cyber livings to bring them into our worlds, wishing to achieve Neuro-samas altitude. Capable of realtime voice chat, Minecraft, Factorio playing. Web / macOS / Windows supported.项目地址: https://gitcode.com/GitHub_Trending/ai/airiAIri是一个基于大型语言模型的虚拟AI角色项目旨在创建可与用户互动、玩游戏、聊天的数字伴侣。在当今云原生应用大行其道的时代容器化部署已成为现代应用交付的标准实践。本文将深入探讨AIri项目的容器化部署方案涵盖从基础Docker部署到生产级Kubernetes集群的完整实践路径为开发者提供从入门到进阶的云原生应用部署指南。项目架构与容器化价值AIri项目采用微服务架构设计包含前端Web应用、后端API服务、数据库、缓存以及可观测性组件等多个模块。容器化部署为AIri带来了显著优势环境一致性确保开发、测试、生产环境完全一致快速部署通过镜像实现秒级部署和回滚资源隔离避免依赖冲突提高系统稳定性弹性伸缩基于容器编排实现自动扩缩容简化运维统一部署和管理接口基础容器化部署方案Docker单机部署实践AIri项目已提供完整的Dockerfile配置位于apps/stage-web/Dockerfile采用多阶段构建优化镜像大小# 构建阶段 FROM node:24-trixie AS build-stage WORKDIR /app COPY . . RUN pnpm install --frozen-lockfile RUN pnpm -F proj-airi/stage-web run build # 生产阶段 FROM nginx:stable-alpine AS production-stage COPY --frombuild-stage /app/apps/stage-web/dist /usr/share/nginx/html EXPOSE 80 CMD [nginx, -g, daemon off;]执行以下命令即可完成基础部署# 克隆项目仓库 git clone https://gitcode.com/GitHub_Trending/ai/airi cd airi # 构建Docker镜像 docker build -t airi-web -f apps/stage-web/Dockerfile . # 运行容器 docker run -d -p 8080:80 --name airi-web-container airi-web完整服务栈部署对于完整的AIri服务栈项目提供了docker-compose配置位于apps/server/docker-compose.ymlservices: db: image: ghcr.io/tensorchord/vchord-postgres:pg18-v1.0.0 environment: - POSTGRES_DBpostgres - POSTGRES_USERpostgres - POSTGRES_PASSWORDexample-PAssw0rd-xHjDYR.b7N ports: - 5435:5432 volumes: - ./sql/init.sql:/docker-entrypoint-initdb.d/init.sql - db_data:/var/lib/postgresql healthcheck: test: [CMD-SHELL, pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB] redis: image: redis:7-alpine ports: - 6379:6379 volumes: - redis_data:/data healthcheck: test: [CMD, redis-cli, ping] api: build: context: ../.. dockerfile: apps/server/Dockerfile command: [pnpm, -F, proj-airi/server, run, server, api] depends_on: db: condition: service_healthy redis: condition: service_healthy ports: - 6112:3000 healthcheck: test: [CMD-SHELL, curl -f http://localhost:3000/livez || exit 1]启动完整服务栈cd apps/server docker-compose up -d生产环境配置优化环境变量管理AIri支持通过环境变量进行灵活配置建议使用.env文件管理敏感信息# .env.production API_KEYyour_production_api_key DATABASE_URLpostgresql://user:passworddb:5432/airi REDIS_URLredis://redis:6379 NODE_ENVproduction LOG_LEVELinfo资源限制与健康检查为生产环境配置合理的资源限制和健康检查策略# docker-compose.prod.yml services: api: deploy: resources: limits: cpus: 2 memory: 2G reservations: cpus: 0.5 memory: 512M healthcheck: test: [CMD, curl, -f, http://localhost:3000/health] interval: 30s timeout: 10s retries: 3 start_period: 40s logging: driver: json-file options: max-size: 10m max-file: 3网络配置优化配置适当的网络策略确保服务安全networks: airi-network: driver: bridge ipam: config: - subnet: 172.20.0.0/16 services: api: networks: - airi-network ports: - target: 3000 published: 6112 protocol: tcp mode: hostKubernetes集群部署方案Deployment配置创建Kubernetes Deployment资源确保高可用性apiVersion: apps/v1 kind: Deployment metadata: name: airi-api labels: app: airi component: api spec: replicas: 3 strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0 selector: matchLabels: app: airi component: api template: metadata: labels: app: airi component: api spec: securityContext: runAsNonRoot: true runAsUser: 1000 fsGroup: 2000 containers: - name: api image: airi-api:latest imagePullPolicy: IfNotPresent ports: - containerPort: 3000 name: http env: - name: DATABASE_URL valueFrom: secretKeyRef: name: airi-secrets key: database-url - name: REDIS_URL valueFrom: configMapKeyRef: name: airi-config key: redis-url resources: requests: memory: 512Mi cpu: 250m limits: memory: 1Gi cpu: 500m livenessProbe: httpGet: path: /health port: 3000 initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: httpGet: path: /ready port: 3000 initialDelaySeconds: 5 periodSeconds: 5Service与Ingress配置配置服务发现和外部访问apiVersion: v1 kind: Service metadata: name: airi-service spec: selector: app: airi ports: - name: http port: 80 targetPort: 3000 type: ClusterIP --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: airi-ingress annotations: nginx.ingress.kubernetes.io/rewrite-target: / nginx.ingress.kubernetes.io/ssl-redirect: true cert-manager.io/cluster-issuer: letsencrypt-prod spec: tls: - hosts: - airi.example.com secretName: airi-tls rules: - host: airi.example.com http: paths: - path: / pathType: Prefix backend: service: name: airi-service port: number: 80可观测性集成AIri项目已集成OpenTelemetry可通过以下配置启用完整的可观测性栈# apps/server/docker-compose.otel.yml 中的配置 services: otel-collector: image: otel/opentelemetry-collector-contrib:0.120.0 command: [--config/etc/otelcol/otel-collector.yaml] ports: - 4317:4317 # OTLP gRPC - 4318:4318 # OTLP HTTP prometheus: image: prom/prometheus:v3.2.1 volumes: - ./otel/prometheus/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro loki: image: grafana/loki:3.4.3 command: -config.file/etc/loki/loki.yaml tempo: image: grafana/tempo:2.7.2 command: [-config.file/etc/tempo/tempo.yaml] grafana: image: grafana/grafana:11.5.2 environment: - GF_SECURITY_ADMIN_USERadmin - GF_SECURITY_ADMIN_PASSWORDadmin ports: - 3001:3000高级部署策略蓝绿部署与金丝雀发布实现零停机部署策略apiVersion: flagger.app/v1beta1 kind: Canary metadata: name: airi-api spec: targetRef: apiVersion: apps/v1 kind: Deployment name: airi-api service: port: 3000 targetPort: 3000 analysis: interval: 1m threshold: 5 maxWeight: 50 stepWeight: 10 metrics: - name: request-success-rate threshold: 99 interval: 1m - name: request-duration threshold: 500 interval: 1m自动扩缩容配置基于资源使用率自动调整副本数量apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: airi-api-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: airi-api minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70 - type: Resource resource: name: memory target: type: Utilization averageUtilization: 80持久化存储配置配置持久化存储确保数据安全apiVersion: v1 kind: PersistentVolumeClaim metadata: name: airi-postgres-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: standard --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: airi-redis-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi storageClassName: standard安全加固实践安全上下文配置实施最小权限原则securityContext: runAsNonRoot: true runAsUser: 1000 allowPrivilegeEscalation: false capabilities: drop: - ALL readOnlyRootFilesystem: true seccompProfile: type: RuntimeDefault网络策略实施限制Pod间网络通信apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: airi-network-policy spec: podSelector: matchLabels: app: airi policyTypes: - Ingress - Egress ingress: - from: - podSelector: matchLabels: role: frontend ports: - protocol: TCP port: 3000 egress: - to: - podSelector: matchLabels: component: database ports: - protocol: TCP port: 5432密钥管理最佳实践使用Kubernetes Secret管理敏感信息# 创建加密Secret kubectl create secret generic airi-secrets \ --from-literalapi-key$(echo -n your-api-key | base64) \ --from-literaldatabase-password$(echo -n secure-password | base64) \ --from-filessl-certificate./cert.pem \ --from-filessl-key./key.pem # 使用外部Secret存储 kubectl create secret generic airi-external-secrets \ --from-literalvault-addrhttps://vault.example.com \ --from-literalvault-token$(cat /path/to/token)监控与告警配置Prometheus监控规则定义关键业务指标监控groups: - name: airi.rules rules: - alert: HighErrorRate expr: | rate(http_requests_total{status~5..}[5m]) / rate(http_requests_total[5m]) 0.05 for: 5m labels: severity: warning annotations: summary: High error rate detected description: Error rate is {{ $value }} for service {{ $labels.service }} - alert: HighLatency expr: | histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])) 1 for: 5m labels: severity: warning annotations: summary: High latency detected description: 95th percentile latency is {{ $value }}s for service {{ $labels.service }}Grafana仪表板配置创建业务监控仪表板{ dashboard: { title: AIri Service Dashboard, panels: [ { title: Request Rate, targets: [{ expr: rate(http_requests_total[5m]), legendFormat: {{method}} {{status}} }] }, { title: Error Rate, targets: [{ expr: rate(http_requests_total{status~\5..\}[5m]) / rate(http_requests_total[5m]), legendFormat: Error Rate }] }, { title: Response Time, targets: [{ expr: histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])), legendFormat: 95th Percentile }] } ] } }持续集成与部署流水线GitHub Actions自动化部署配置完整的CI/CD流水线name: Deploy AIri to Production on: push: branches: [ main ] pull_request: branches: [ main ] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkoutv4 - name: Setup Node.js uses: actions/setup-nodev4 with: node-version: 20 - name: Install pnpm uses: pnpm/action-setupv2 with: version: 8 - name: Install dependencies run: pnpm install --frozen-lockfile - name: Run tests run: pnpm test build-and-push: needs: test runs-on: ubuntu-latest steps: - uses: actions/checkoutv4 - name: Set up Docker Buildx uses: docker/setup-buildx-actionv3 - name: Log in to Docker Hub uses: docker/login-actionv3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push Docker image uses: docker/build-push-actionv5 with: context: . file: ./apps/stage-web/Dockerfile push: true tags: | ${{ secrets.DOCKER_USERNAME }}/airi-web:latest ${{ secrets.DOCKER_USERNAME }}/airi-web:${{ github.sha }} deploy: needs: build-and-push runs-on: ubuntu-latest steps: - name: Deploy to Kubernetes uses: azure/k8s-deployv4 with: namespace: production manifests: | k8s/deployment.yaml k8s/service.yaml k8s/ingress.yaml images: | ${{ secrets.DOCKER_USERNAME }}/airi-web:${{ github.sha }}故障排除与优化建议常见部署问题解决镜像构建失败检查Dockerfile语法和依赖版本验证构建上下文文件完整性检查网络代理配置容器启动失败查看容器日志docker logs container-id检查环境变量配置验证端口冲突和资源限制服务连接问题检查网络策略和防火墙规则验证服务发现配置检查健康检查端点性能优化建议镜像优化使用多阶段构建减少镜像大小合理利用构建缓存移除不必要的依赖和文件资源配置根据监控数据调整资源限制设置合理的副本数量配置垂直和水平自动扩缩容网络优化使用服务网格进行流量管理配置合适的负载均衡策略优化DNS解析配置总结AIri项目的容器化部署方案展示了现代云原生应用的最佳实践。通过本文介绍的部署策略开发者可以快速搭建开发环境进行本地测试构建生产就绪的Docker镜像部署到Kubernetes集群实现高可用配置完整的可观测性栈进行监控实施安全加固和自动化部署随着AIri项目的持续发展容器化部署将为项目带来更好的可维护性、可扩展性和可靠性。建议开发者根据实际业务需求结合本文提供的配置模板制定适合自身环境的部署方案。通过采用这些容器化部署实践AIri项目能够在各种云环境和本地基础设施中稳定运行为用户提供高质量的虚拟AI角色体验。【免费下载链接】airi Self hosted, you-owned Grok Companion, a container of souls of waifu, cyber livings to bring them into our worlds, wishing to achieve Neuro-samas altitude. Capable of realtime voice chat, Minecraft, Factorio playing. Web / macOS / Windows supported.项目地址: https://gitcode.com/GitHub_Trending/ai/airi创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考