mirror of https://github.com/veops/cmdb.git
update Makefile and support for install by make
This commit is contained in:
parent
63cae8510f
commit
00f6e8e7d9
30
Makefile
30
Makefile
|
@ -1,25 +1,37 @@
|
|||
.PHONY: docs test
|
||||
.PHONY: env clean api ui worker
|
||||
|
||||
help:
|
||||
@echo " env create a development environment using virtualenv"
|
||||
@echo " env create a development environment using pipenv"
|
||||
@echo " deps install dependencies using pip"
|
||||
@echo " clean remove unwanted files like .pyc's"
|
||||
@echo " lint check style with flake8"
|
||||
@echo " test run all your tests using py.test"
|
||||
@echo " api start api server"
|
||||
@echo " ui start ui server"
|
||||
@echo " worker start async tasks worker"
|
||||
|
||||
env:
|
||||
sudo easy_install pip && \
|
||||
pip install pipenv &&
|
||||
pip install pipenv -i https://pypi.douban.com/simple && \
|
||||
npm install yarn && \
|
||||
make deps
|
||||
|
||||
deps:
|
||||
pipenv install --dev
|
||||
pipenv install --dev && \
|
||||
pipenv run flask db-setup && \
|
||||
pipenv run flask init-cache && \
|
||||
cd ui && yarn install && cd ..
|
||||
|
||||
api:
|
||||
pipenv run flask run -h 0.0.0.0
|
||||
|
||||
worker:
|
||||
pipenv run celery worker -A celery_worker.celery -E -Q cmdb_async --concurrency=1
|
||||
|
||||
ui:
|
||||
cd ui && yarn run serve
|
||||
|
||||
clean:
|
||||
python manage.py clean
|
||||
pipenv run flask clean
|
||||
|
||||
lint:
|
||||
flake8 --exclude=env .
|
||||
|
||||
test:
|
||||
py.test tests
|
30
README.md
30
README.md
|
@ -29,7 +29,7 @@ Overview
|
|||
- python版本: python2.7, >=python3.6
|
||||
|
||||
|
||||
安装
|
||||
Install
|
||||
----
|
||||
- 启动mysql服务, redis服务
|
||||
|
||||
|
@ -40,23 +40,45 @@ git clone https://github.com/pycook/cmdb.git
|
|||
cd cmdb
|
||||
cp api/settings.py.example api/settings.py
|
||||
```
|
||||
设置api/settings.py里的database
|
||||
**设置api/settings.py里的database**
|
||||
|
||||
- 安装库
|
||||
- 后端: ```pipenv run pipenv install```
|
||||
- 前端: ```cd ui && yarn install && cd ..```
|
||||
|
||||
- 创建数据库表 ```pipenv run flask db-setup```
|
||||
- 创建数据库表 ```pipenv run flask db-setup && pipenv run flask init-cache```
|
||||
- 可以将docs/cmdb.sql导入到数据库里,登录用户和密码都是:admin
|
||||
|
||||
- 启动服务
|
||||
- 后端: ```pipenv run flask run -h 0.0.0.0```
|
||||
- 前端: ```cd ui && yarn run serve```
|
||||
- worker: ```celery worker -A celery_worker.celery -E -Q cmdb_async --concurrency=1```
|
||||
|
||||
- 浏览器打开: [http://127.0.0.1:8000](http://127.0.0.1:8000)
|
||||
- 如果是非本机访问, 要修改**ui/.env**里**VUE_APP_API_BASE_URL**里的IP地址为后端服务的ip地址
|
||||
|
||||
docker 一键构建和运行
|
||||
|
||||
Install by Makefile
|
||||
----
|
||||
- 启动mysql服务, redis服务
|
||||
|
||||
- 创建数据库cmdb
|
||||
- 拉取代码
|
||||
```bash
|
||||
git clone https://github.com/pycook/cmdb.git
|
||||
cd cmdb
|
||||
cp api/settings.py.example api/settings.py
|
||||
```
|
||||
**设置api/settings.py里的database**
|
||||
|
||||
- 顺序在cmdb目录下执行
|
||||
- 环境: ```make env```
|
||||
- 启动API: ```make api```
|
||||
- 启动UI: ```make ui```
|
||||
- 启动worker: ```make worker```
|
||||
|
||||
|
||||
Install by Docker
|
||||
----
|
||||
- 进入主目录(首次镜像的构建需要**10分钟**左右,视网络情况而定)
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue