{"id":16970280,"url":"https://github.com/wanghaoxi3000/advproject","last_synced_at":"2025-04-12T00:21:26.282Z","repository":{"id":47151818,"uuid":"237172307","full_name":"wanghaoxi3000/advproject","owner":"wanghaoxi3000","description":"一个基于Gin框架，以DevOps开发模式搭建的项目模板","archived":false,"fork":false,"pushed_at":"2021-09-11T06:24:42.000Z","size":45,"stargazers_count":7,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T20:06:06.246Z","etag":null,"topics":["devops","dockerfile","gin","jenkinsfile","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wanghaoxi3000.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-30T08:44:43.000Z","updated_at":"2022-11-24T01:58:05.000Z","dependencies_parsed_at":"2022-08-20T07:10:53.536Z","dependency_job_id":null,"html_url":"https://github.com/wanghaoxi3000/advproject","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghaoxi3000%2Fadvproject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghaoxi3000%2Fadvproject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghaoxi3000%2Fadvproject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wanghaoxi3000%2Fadvproject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wanghaoxi3000","download_url":"https://codeload.github.com/wanghaoxi3000/advproject/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248498092,"owners_count":21114037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devops","dockerfile","gin","jenkinsfile","kubernetes"],"created_at":"2024-10-14T00:27:50.743Z","updated_at":"2025-04-12T00:21:26.258Z","avatar_url":"https://github.com/wanghaoxi3000.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# advproject\n一个基于Gin框架，以DevOps开发模式搭建的项目模板。\n\n## 项目组成\n\u003e DevOps 集文化理念、实践和工具于一身，可以提高组织高速交付应用程序和服务的能力，与使用传统软件开发和基础设施管理流程相比，能够帮助组织更快地发展和改进产品。这种速度使组织能够更好地服务其客户，并在市场上更高效地参与竞争。\n\n- 持续集成：一种软件开发实践经验，开发人员会定期将他们的代码变更合并到一个中央存储库中，之后系统会自动运行构建和测试操作\n    - GitHub\n    - webhook 推送 Jenkins\n- 持续交付付：自动构建和测试代码更改，并为将其发布到生产环境做好准备，实现对持续集成的扩展\n    - Jenkins Pipeline 测试，生成镜像，部署\n- 基础设施即代码：使用基于代码的工具来连接基础设施，并且能够以处理应用程序代码的方式来处理基础设施。基础设施和服务器由代码进行定义。\n    - [Dockerfile](Dockerfile) 打包Docker镜像\n    - [Jenkinsfile](Jenkinsfile) 定义Jenkins Pipeline流程\n    - [deployment](deployment-template.yaml) k8s Deployment 部署声明\n- 监控和日志记录：组织对各项指标和日志进行监控，以了解应用程序和基础设施性能如何影响其产品的最终用户体验\n    - [zap](https://github.com/uber-go/zap) 结构化日志输出，可配合k8s ELK插件使用\n    - k8s livenessProbe 容器健康检查\n\n\n## 配置说明\n### 接口文档\n安装swag cli\n```\n$ go get -u github.com/swaggo/swag/cmd/swag\n```\n\n生成API文档，每次接口说明有更新都需要更新\n```\n$ swag init\n```\n\n接口文档地址: http://localhost:3000/swagger/index.html\n\n### 系统配置\n默认配置硬编码在config模块中，可通过环境变量覆盖，开发时在项目目录下新建`.env`文件来快速修改环境变量。\n\n变量名 | 说明 | 默认值 | 可选值\n---|---|---|---\nRUN_MODE | 测试/生产环境 | develop | develop, prod\n\n### 日志输出\n使用Uber开源的高性能日志框架[zap](https://github.com/uber-go/zap)来作为日志输出，直接使用了zap默认的格式配置，在develop开发环境下以易读的行模式输出，prod生产下以结构化模式输出。\n\n### 状态接口\n- 状态输出，用于定时请求进行健康检查 `/api/v1/status`\n- hostname输出，在多节点部署时测试是哪个节点 `/api/v1/hostname`\n\n### Jenkinsfile\nJenkinsfile 中镜像存储使用了腾讯云容器服务的私有镜像仓库和 [Server酱](http://sc.ftqq.com/3.version) 来推送通知，可根据实际修改。同时通过变量名来使用了一些私有密钥，需要提前在Jenkins的凭证管理中提前配置：\n\n- tcloud-docker-reg 镜像仓库访问密钥\n- kubctl-config kubectl密钥文件\n- PUSH_KEY Server酱通知推送的密钥\n\n### k8s deployment\n[deployment-template.yaml](deployment-template.yaml)中定义Kubernetes部署模板，通过image指定了拉取镜像的地址，可根据需要修改。`imagePullSecrets`中使用了拉取私有镜像的config name，需要提前在k8s中配置。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanghaoxi3000%2Fadvproject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwanghaoxi3000%2Fadvproject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwanghaoxi3000%2Fadvproject/lists"}