From 7044b171f1f6a0a7f4aa363c14adb52f99e7263f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=8E=89=E5=9D=A1?= Date: Wed, 28 Feb 2018 11:56:46 +0800 Subject: [PATCH] U - Update README.md and Docs --- README.md | 24 +++-- docs/Dockerfile/Dockerfile | 7 +- docs/Dockerfile/entrypoint.sh | 2 +- docs/Dockerfile/scripts/init_config.sh | 11 ++ docs/Dockerfile/scripts/init_spug.py | 4 +- docs/project_structure.md | 144 ++++++++++++------------- 6 files changed, 104 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index 0eabe90..82eee6e 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,18 @@ Spug是一款使用Python+Flask+Element组件开发的开源运维管理系统, ---------------------------- ``` $ 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_USER="spuguser" //指定数据库用户名 - -e MYSQL_PASSWORD="spugpwd" //指定数据库密码 - -e REGISTRY_SERVER="hub.docker.com:5000" //指定私有镜像仓库 - -e REGISTRY_USER="hubuser" //指定私有镜像仓库用户名 - -e REGISTRY_PASSWORD="hubpwd" //指定私有镜像仓库密码 +$ -e MYSQL_DATABASE="spug" //指定数据库名称 + -e MYSQL_USER="spuguser" //指定数据库用户名 + -e MYSQL_PASSWORD="spugpwd" //指定数据库密码 + -e REGISTRY_SERVER="hub.qbangmang.com:5000" //指定私有镜像仓库 + -e REGISTRY_USER="hubuser" //指定私有镜像仓库用户名 + -e REGISTRY_PASSWORD="hubpwd" //指定私有镜像仓库密码 ``` 更多Dockerfile [Dockerfile](https://github.com/openspug/spug/docs/Dockerfile) @@ -65,8 +67,10 @@ $ -e MYSQL_DATABASE="spug"       //指定数据库名称   2. Start server 启动服务端: $ cd spug/spug_api - $ pip install -r requirements.txt -   $ python main.py + $ pip install -r requirements.txt //安装依赖包 + $ python manage.py init_db //初始化数据库 + $ python manage.py create_admin //创建管理员 +   $ python main.py //启动服务 3. Start web 启动前端: $ cd spug/spug_web @@ -86,7 +90,7 @@ $ -e MYSQL_DATABASE="spug"       //指定数据库名称 ### 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 贡献者 ---------------------------- diff --git a/docs/Dockerfile/Dockerfile b/docs/Dockerfile/Dockerfile index 6b4fc26..cd34ebf 100644 --- a/docs/Dockerfile/Dockerfile +++ b/docs/Dockerfile/Dockerfile @@ -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 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 \ + && 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 gunicorn \ + && pip3 install --no-cache-dir gunicorn \ && apk del .build-deps RUN cd /spug/spug_web/ && npm i -d --registry=https://registry.npm.taobao.org \ && npm run build \ - && mv /var/lib/nginx/html /var/lib/nginx/html.bak && mv /spug/spug_web/dist /var/lib/nginx/html \ - && rm -f /spug/spug_web + && mv /var/lib/nginx/html /var/lib/nginx/html.bak && mv /spug/spug_web/dist /var/lib/nginx/html \ + && rm -rf /spug/spug_web ADD default.conf /etc/nginx/conf.d/default.conf ADD entrypoint.sh /entrypoint.sh diff --git a/docs/Dockerfile/entrypoint.sh b/docs/Dockerfile/entrypoint.sh index 6ae1a0b..fc764b7 100644 --- a/docs/Dockerfile/entrypoint.sh +++ b/docs/Dockerfile/entrypoint.sh @@ -37,4 +37,4 @@ sleep 2 if [ $REQUIRE_INIT_OPS == true ]; then /usr/bin/python3 /scripts/init_spug.py fi -gunicorn --threads=32 main:app +gunicorn --threads=32 main:app -b 0.0.0.0:3000 diff --git a/docs/Dockerfile/scripts/init_config.sh b/docs/Dockerfile/scripts/init_config.sh index aede3a8..474144c 100644 --- a/docs/Dockerfile/scripts/init_config.sh +++ b/docs/Dockerfile/scripts/init_config.sh @@ -1,5 +1,16 @@ 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 "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 diff --git a/docs/Dockerfile/scripts/init_spug.py b/docs/Dockerfile/scripts/init_spug.py index 2aac567..1a31af1 100644 --- a/docs/Dockerfile/scripts/init_spug.py +++ b/docs/Dockerfile/scripts/init_spug.py @@ -1,6 +1,6 @@ import sys import os -sys.path.append('/ops_api') +sys.path.append('/spug/spug_api') import random import string 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 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() print('*' * 80) diff --git a/docs/project_structure.md b/docs/project_structure.md index 7db2350..30352d1 100644 --- a/docs/project_structure.md +++ b/docs/project_structure.md @@ -2,89 +2,89 @@ ``` - docs // ĵĿ¼ + docs // ĵĿ¼ spug_api // ˽ӿĿ¼ apps // ģĿ¼ account // ûģ __init__.py // ûģͼ· - models.py // ûģģ - role.py // ûȨ޲ط - user.py // ûط - apis // ýӿģ + models.py // ûģģ + role.py // ûȨ޲ط + user.py // ûط + apis // ýӿģ __init__.py // ӿͼ· - config.py // ͻ˻ȡļط + config.py // ͻ˻ȡļط files.py // ļϴط utils.py // assets // ʲģ __init__.py // ʲģͼ· - host.py // ط + host.py // ط host_exec.py // ִط - models.py // ʲģģ + models.py // ʲģģ utils.py // common // öģ __init__.py // öģͼ· queue.py // öз configuration // ùģ __init__.py // ùģͼ· - app.py // ط - config.py // - environment.py // ط - models.py // ùģ - service.py // ù-ط - deploy // Ӧ÷ģ + app.py // Ӧù + config.py // + environment.py // ط + models.py // ùģ + service.py // ù-ط + deploy // Ӧ÷ģ __init__.py // Ӧ÷ģͼ· - app.py // - config.py // + app.py // + config.py // container.py // - exec.py // Ӧ÷-ִзط - field.py // Ӧ÷-ֶιط - host.py // - image.py // Ӧ÷-ط - menu.py // Ӧ÷-˵ - models.py // Ӧ÷ģ - publish.py // Ӧ÷-ط - utils.py // + exec.py // Ӧ÷-ִзط + field.py // Ӧ÷-ֶιط + host.py // + image.py // Ӧ÷-ط + menu.py // Ӧ÷-˵ + models.py // Ӧ÷ģ + publish.py // Ӧ÷-ط + utils.py // home // ҳģ __init__.py // ҳͼ· homes.py // ҳչʾݷ - schedule // ģ + schedule // ģ __init__.py // ͼ· agent.py // -ִжط - history.py // -ʷ - job.py // -б - models.py // ģ + history.py // -ʷ + job.py // -б + models.py // ģ scheduler.py // - setting // + setting // __init__.py // - models.py // - utils.py // + models.py // + utils.py // __init__.py // - + libs // ϵͳÿĿ¼ scripts // ýűĿ¼ entrypoint.sh // ű - sql // sqlĿ¼ + sql // sqlĿ¼ permissions.sql // ϵͳȨSQLļ - ssh // sshĿ¼ + ssh // sshĿ¼ __init__.py // sshط template // ϵͳģĿ¼ - host.xls // --ģ - __init__.py // + host.xls // --ģ + __init__.py // decorators.py // üȨļ middleware.py // ϵͳļ model.py // ϵͳ tool.py // ϵͳùļ - utils.py // + utils.py // storage // ϵͳĿ¼ exec_tmp // ִĿ¼ images // Ŀ¼ publish_tmp // Ŀ¼ config.py.example // ļģ - main.py // ļģ - manage.py // ϵͳļ - public.py // ϵͳ + main.py // ļģ + manage.py // ϵͳļ + public.py // ϵͳ requirements.txt // ļ - + spug_web // ǰĿ¼ dist // Ŀľ̬ԴĿ¼ @@ -96,55 +96,55 @@ PublishPermission.vue // ɫȨ-Ȩ Role.vue // ɫȨ routes.js // û· - TagTd.vue // Ȩ޹ǩ + TagTd.vue // Ȩ޹ǩ User.vue // ûб assets // Ŀ¼ - Host.vue // б + Host.vue // б HostExec.vue // ִ route.js // · configuration // ùĿ¼ - App.vue // Ӧб - AppConfig.vue // Ӧ- - AppRel.vue // Ӧ-ϵ - ConfigEdie.vue // - Environment.vue // + App.vue // Ӧб + AppConfig.vue // Ӧ- + AppRel.vue // Ӧ-ϵ + ConfigEdie.vue // + Environment.vue // route.js // ù· - Service.vue // + Service.vue // ServiceConfig.vue// - - publish // Ӧ÷Ŀ¼ - App.vue // Ӧб - AppConfig.vue // Ӧб-Ӧ - AppMenu.vue // - AppSetting.vue // Ӧб- - ColorInput.vue // ִ - Deploy.vue // Ӧ÷- - Field.vue // Ӧ÷-ֶι - Image.vue // Ӧ÷- - Menu.vue // Ӧ÷-˵ + publish // Ӧ÷Ŀ¼ + App.vue // Ӧб + AppConfig.vue // Ӧб-Ӧ + AppMenu.vue // + AppSetting.vue // Ӧб- + ColorInput.vue // ִ + Deploy.vue // Ӧ÷- + Field.vue // Ӧ÷-ֶι + Image.vue // Ӧ÷- + Menu.vue // Ӧ÷-˵ MenuExec.vue // route.js // Ӧ÷· schedule // Ŀ¼ - Job.vue // б - JobSetting.vue // -ô - Deny.vue // ȫȨ޾ܾ - Home.vue // ϵͳHome - Layout.vue // ˵ - Login.vue // ϵͳ¼ - config // Ŀ¼ + Job.vue // б + JobSetting.vue // -ô + Deny.vue // ȫȨ޾ܾ + Home.vue // ϵͳHome + Layout.vue // ˵ + Login.vue // ϵͳ¼ + config // Ŀ¼ env.js // Ŀ menu.js // ˵м - plugins // ĿչĿ¼ + plugins // ĿչĿ¼ globalTools.js // ȫֱ - App.vue // + App.vue // index.html // ҳļ - main.js // ļظֹ + main.js // ļظֹ router.js // · .babelrc // ES6﷨ - Makefile // + Makefile // package.json // Ŀߵļ - postcss.config.js // + postcss.config.js // ReadME.md // ǰREADME - webpack.config.js // + webpack.config.js // ``` \ No newline at end of file