-
环境依赖: python 3.6、MySQL 5.7+、Redis 3.2
-
PIP源
[global] index-url=https://mirrors.tencent.com/repository/pypi/tencent_pypi/simple extra-index-url=http://mirrors.cloud.tencent.com/pypi/simple/ trusted-host = mirrors.tencent.com, mirrors.cloud.tencent.com
-
PIP版本
PIP 版本需要满足
pip==20.2.3
,在 Paas 中增加环境变量PIP_VERSION=20.2.3
声明,本地可以使用pip install --upgrade pip==20.2.3
安装指定版本
- 申请git仓库
- 创建蓝鲸APP,获取app_id、app_secret
-
提交代码
cd {app_id} git init git add . git commit -m "minor: init repo" git remote add origin {git_url} git push -u origin master
- Codebase - One codebase tracked in revision control, many deploys
Manage project code and version easily with Git repository, all services of project can be stored in one repo - Dependencies - Explicitly declare and isolate dependencies
Declare dependencies in requirements.txt and manage them with PIP - Config - Store config in the environment
All variable configs are loaded from environment for safe and reusable,.env
file is also helpful for deploying and migrating services - Backing services - Treat backing services as attached resources
Using Django ORM or Django Cache Client, MySQL, Redis or other backing services are attached resources - Build, release, run - Strictly separate build and run stages
Running stages are seperated by Blueking PaaS, which provides two environment, staging and prodcution, the PaaS build service first and the deploy it on BCS - Processes - Execute the app as one or more stateless processes
Service is stateless with DRF, receives request and then sends response, all data a response needs comes from database or request - Port binding - Export services via port binding
Binding a port is necessary to run service - Concurrency - Scale out via the process model
Using Gunicorn for HTTP request and Celery for backend service, both of them support concurrency - Disposability - Maximize robustness with fast startup and graceful shutdown
Services start and shutdown fast, and when deploying on Blueking PaaS, it's undetectable when rollup - Dev/prod parity - Keep development, staging, and production as similar as possible
Blueking PaaS provides almost the same running environment for staging and production - Logs - Treat logs as event streams
All logs is collected to BkLog while using Blueking PaaS - Admin processes - Run admin/management tasks as one-off processes
Django's manage commands are all running as one-off processes, run and then exit