U - Update README.md and Docs

pull/11/head
张玉坡 2018-02-28 11:56:46 +08:00
parent 1cdc5a7503
commit 7044b171f1
6 changed files with 104 additions and 88 deletions

View File

@ -36,14 +36,16 @@ Spug是一款使用Python+Flask+Element组件开发的开源运维管理系统,
---------------------------- ----------------------------
``` ```
$ docker pull hub.qbangmang.com/spug:1.0.1 $ docker pull hub.qbangmang.com/spug:1.0.1
$ docker run -d -e REGISTRY_SERVER="hub.docker.com:5000" -p 80:80 hub.qbangmang.com/spug:1.0.1 $ docker run -d -e REGISTRY_SERVER="hub.qbangmang.com:5000" -p 80:80 hub.qbangmang.com/spug:1.0.1
$ 访问http://主机ip
$ 默认账号密码admin/spug
# 可选参数: # 可选参数:
$ -e MYSQL_DATABASE="spug"       //指定数据库名称 $ -e MYSQL_DATABASE="spug" //指定数据库名称
-e MYSQL_USER="spuguser" //指定数据库用户名 -e MYSQL_USER="spuguser" //指定数据库用户名
-e MYSQL_PASSWORD="spugpwd" //指定数据库密码 -e MYSQL_PASSWORD="spugpwd" //指定数据库密码
-e REGISTRY_SERVER="hub.docker.com:5000" //指定私有镜像仓库 -e REGISTRY_SERVER="hub.qbangmang.com:5000" //指定私有镜像仓库
-e REGISTRY_USER="hubuser" //指定私有镜像仓库用户名 -e REGISTRY_USER="hubuser" //指定私有镜像仓库用户名
-e REGISTRY_PASSWORD="hubpwd" //指定私有镜像仓库密码 -e REGISTRY_PASSWORD="hubpwd" //指定私有镜像仓库密码
``` ```
@ -65,8 +67,10 @@ $ -e MYSQL_DATABASE="spug"       //指定数据库名称
  2. Start server 启动服务端:   2. Start server 启动服务端:
$ cd spug/spug_api $ cd spug/spug_api
$ pip install -r requirements.txt $ pip install -r requirements.txt //安装依赖包
  $ python main.py $ python manage.py init_db //初始化数据库
$ python manage.py create_admin //创建管理员
  $ python main.py //启动服务
3. Start web 启动前端: 3. Start web 启动前端:
$ cd spug/spug_web $ cd spug/spug_web
@ -86,7 +90,7 @@ $ -e MYSQL_DATABASE="spug"       //指定数据库名称
### Docs 开发者文档 ### Docs 开发者文档
---------------------------- ----------------------------
* [Project structure 项目结构](https://github.com/openspug/spug/docs/project_structure.md) * [Project structure 项目结构](https://github.com/openspug/spug/blob/master/docs/project_structure.md)
### Contributor 贡献者 ### Contributor 贡献者
---------------------------- ----------------------------

View File

@ -3,13 +3,14 @@ FROM alpine:3.6
RUN echo -e "http://mirrors.aliyun.com/alpine/v3.6/main\nhttp://mirrors.aliyun.com/alpine/v3.6/community" > /etc/apk/repositories RUN echo -e "http://mirrors.aliyun.com/alpine/v3.6/main\nhttp://mirrors.aliyun.com/alpine/v3.6/community" > /etc/apk/repositories
RUN apk update && apk add --no-cache ca-certificates python3 nginx mariadb nodejs-npm git RUN apk update && apk add --no-cache ca-certificates python3 nginx mariadb nodejs-npm git
RUN apk add --no-cache --virtual .build-deps python3-dev gcc musl-dev libffi-dev openssl-dev make \ RUN apk add --no-cache --virtual .build-deps python3-dev gcc musl-dev libffi-dev openssl-dev make \
&& git clone https://github.com/openspug/spug.git /spug \
&& pip3 install --no-cache-dir -r /spug/spug_api/requirements.txt \ && pip3 install --no-cache-dir -r /spug/spug_api/requirements.txt \
&& pip3 install --no-cache-dir gunicorn \ && pip3 install --no-cache-dir gunicorn \
&& apk del .build-deps && apk del .build-deps
RUN cd /spug/spug_web/ && npm i -d --registry=https://registry.npm.taobao.org \ RUN cd /spug/spug_web/ && npm i -d --registry=https://registry.npm.taobao.org \
&& npm run build \ && npm run build \
&& mv /var/lib/nginx/html /var/lib/nginx/html.bak && mv /spug/spug_web/dist /var/lib/nginx/html \ && mv /var/lib/nginx/html /var/lib/nginx/html.bak && mv /spug/spug_web/dist /var/lib/nginx/html \
&& rm -f /spug/spug_web && rm -rf /spug/spug_web
ADD default.conf /etc/nginx/conf.d/default.conf ADD default.conf /etc/nginx/conf.d/default.conf
ADD entrypoint.sh /entrypoint.sh ADD entrypoint.sh /entrypoint.sh

View File

@ -37,4 +37,4 @@ sleep 2
if [ $REQUIRE_INIT_OPS == true ]; then if [ $REQUIRE_INIT_OPS == true ]; then
/usr/bin/python3 /scripts/init_spug.py /usr/bin/python3 /scripts/init_spug.py
fi fi
gunicorn --threads=32 main:app gunicorn --threads=32 main:app -b 0.0.0.0:3000

View File

@ -1,5 +1,16 @@
set -e set -e
cat >> /spug/spug_api/config.py << EOF
from pytz import timezone
import os
DEBUG = True
TIME_ZONE = timezone('Asia/Shanghai')
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DOCKER_URL = 'unix:///var/run/docker.sock'
SQLALCHEMY_ECHO = False
EOF
echo "SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://${MYSQL_USER:-spuguser}:${MYSQL_PASSWORD:-spugpwd}@localhost/${MYSQL_DATABASE:-spug}'" >> /spug/spug_api/config.py echo "SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://${MYSQL_USER:-spuguser}:${MYSQL_PASSWORD:-spugpwd}@localhost/${MYSQL_DATABASE:-spug}'" >> /spug/spug_api/config.py
echo "DOCKER_REGISTRY_SERVER = '${REGISTRY_SERVER}'" >> /spug/spug_api/config.py echo "DOCKER_REGISTRY_SERVER = '${REGISTRY_SERVER}'" >> /spug/spug_api/config.py
echo "DOCKER_REGISTRY_AUTH = {'username': '${REGISTRY_USER}', 'password': '${REGISTRY_PASSWORD}'}" >> /spug/spug_api/config.py echo "DOCKER_REGISTRY_AUTH = {'username': '${REGISTRY_USER}', 'password': '${REGISTRY_PASSWORD}'}" >> /spug/spug_api/config.py

View File

@ -1,6 +1,6 @@
import sys import sys
import os import os
sys.path.append('/ops_api') sys.path.append('/spug/spug_api')
import random import random
import string import string
from public import db from public import db
@ -25,7 +25,7 @@ with open(os.path.join(BASE_DIR, 'libs', 'sql', 'permissions.sql'), 'r') as f:
# create default admin # create default admin
username = 'admin' username = 'admin'
password = ''.join(random.sample(string.ascii_letters + string.digits, 8)) password = 'spug'
User(username=username, password=password, nickname='Administrator', is_supper=True).save() User(username=username, password=password, nickname='Administrator', is_supper=True).save()
print('*' * 80) print('*' * 80)

View File

@ -26,7 +26,7 @@
│ │ │ └── queue.py // 公用队列方法 │ │ │ └── queue.py // 公用队列方法
│ │ ├── configuration // 配置管理模块 │ │ ├── configuration // 配置管理模块
│ │ │ └── __init__.py // 配置管理模块蓝图路由 │ │ │ └── __init__.py // 配置管理模块蓝图路由
│ │ │ └── app.py // 主机管理相关方法 │ │ │ └── app.py // 应用配置管理
│ │ │ └── config.py // │ │ │ └── config.py //
│ │ │ └── environment.py // 环境配置相关方法 │ │ │ └── environment.py // 环境配置相关方法
│ │ │ └── models.py // 配置管理数据模型 │ │ │ └── models.py // 配置管理数据模型