From 31a59a2bf189e75f0345747170fb45a494f9afca Mon Sep 17 00:00:00 2001 From: Heaven Date: Tue, 9 Jun 2020 15:18:06 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=89=93=E5=8C=85?= =?UTF-8?q?=E9=95=9C=E5=83=8F,=E5=B0=86=E7=8E=AF=E5=A2=83=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=85=A8=E9=83=A8=E8=BD=AC=E4=B8=BA=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=86=85=E6=9D=A5=E6=93=8D=E4=BD=9C=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 31 +----- doc/codo_admin_beta0.3.sql | 128 ----------------------- docker-compose.yml | 8 -- docker/docker-compose.yml | 16 +++ docker/env.sh | 76 ++++++++++++++ {doc => docker}/nginx_ops.conf | 0 docker/prestart.sh | 24 +++++ {doc => docker}/supervisor_ops.conf | 14 ++- doc/requirements.txt => requirements.txt | 0 9 files changed, 134 insertions(+), 163 deletions(-) delete mode 100644 doc/codo_admin_beta0.3.sql delete mode 100644 docker-compose.yml create mode 100644 docker/docker-compose.yml create mode 100644 docker/env.sh rename {doc => docker}/nginx_ops.conf (100%) create mode 100644 docker/prestart.sh rename {doc => docker}/supervisor_ops.conf (73%) rename doc/requirements.txt => requirements.txt (100%) diff --git a/Dockerfile b/Dockerfile index 0dd7971..56f20e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,14 @@ -FROM centos:7 -# 设置编码 -ENV LANG en_US.UTF-8 -# 同步时间 -ENV TZ=Asia/Shanghai -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +FROM registry.cn-hangzhou.aliyuncs.com/sourcegarden/python:centos7-3.6 -# 1. 安装基本依赖 -RUN yum update -y && yum install epel-release -y && yum update -y && yum install wget unzip epel-release nginx xz gcc automake zlib-devel openssl-devel supervisor groupinstall development libxslt-devel libxml2-devel libcurl-devel git -y -#WORKDIR /var/www/ - -# 2. 准备python -RUN wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz -RUN xz -d Python-3.6.6.tar.xz && tar xvf Python-3.6.6.tar && cd Python-3.6.6 && ./configure && make && make install - -# 3. 安装pip依赖 -RUN pip3 install --upgrade pip -RUN pip3 install -U git+https://github.com/ss1917/ops_sdk.git - -# 4. 复制代码 RUN mkdir -p /var/www/ ADD . /var/www/codo-admin/ -# 5. 安装pip依赖 -RUN pip3 install -r /var/www/codo-admin/doc/requirements.txt +RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r /var/www/codo-admin/doc/requirements.txt -# 6. 日志 -VOLUME /var/log/ +#VOLUME /var/log/ -# 7. 准备文件 -COPY doc/nginx_ops.conf /etc/nginx/conf.d/default.conf -COPY doc/supervisor_ops.conf /etc/supervisord.conf +COPY docker/nginx_ops.conf /etc/nginx/conf.d/default.conf +COPY docker/supervisor_ops.conf /etc/supervisord.conf EXPOSE 80 CMD ["/usr/bin/supervisord"] \ No newline at end of file diff --git a/doc/codo_admin_beta0.3.sql b/doc/codo_admin_beta0.3.sql deleted file mode 100644 index d474d2e..0000000 --- a/doc/codo_admin_beta0.3.sql +++ /dev/null @@ -1,128 +0,0 @@ --- MySQL dump 10.14 Distrib 5.5.60-MariaDB, for Linux (x86_64) --- --- Host: 127.0.0.1 Database: codo_admin --- ------------------------------------------------------ --- Server version 5.7.26 - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; -/*!40103 SET TIME_ZONE='+00:00' */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - --- --- Dumping data for table `mg_app_settings` --- - -LOCK TABLES `mg_app_settings` WRITE; -/*!40000 ALTER TABLE `mg_app_settings` DISABLE KEYS */; -/*!40000 ALTER TABLE `mg_app_settings` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_components` --- - -LOCK TABLES `mg_components` WRITE; -/*!40000 ALTER TABLE `mg_components` DISABLE KEYS */; -INSERT INTO `mg_components` VALUES (2,'edit_button','0'),(3,'publish_button','0'),(8,'reset_mfa_btn','0'),(9,'reset_pwd_btn','0'),(10,'new_user_btn','0'),(12,'get_token_btn','0'),(13,'web_ssh_btn','0'),(14,'asset_error_log','0'); -/*!40000 ALTER TABLE `mg_components` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_functions` --- - -LOCK TABLES `mg_functions` WRITE; -/*!40000 ALTER TABLE `mg_functions` DISABLE KEYS */; -INSERT INTO `mg_functions` VALUES (6,'ss','/login/','ALL','10','2018-03-21 10:29:14','2018-03-20 18:35:24'),(9,'管理员','/','ALL','0','2018-03-21 14:04:59','2018-03-21 14:04:59'),(10,'任务管理员','/task/v2/task/','ALL','0','2019-03-21 10:57:54','2018-03-22 10:09:10'),(12,'修改密码','/mg/v2/accounts/password/','PATCH','0','2019-03-21 11:07:20','2018-03-22 16:27:12'),(15,'提交任务','/task/v2/task/accept/','POST','0','2019-03-21 10:57:29','2018-06-08 09:26:00'),(16,'获取CSRF','/task/v2/task/accept/','GET','0','2018-12-27 13:16:41','2018-06-08 09:26:51'),(33,'发布配置','/task/v2/task_other/publish_cd/','GET','0','2018-12-05 09:59:48','2018-12-05 09:37:24'),(35,'系统用户获取','/mg/v2/accounts/','GET','0','2018-12-14 14:44:51','2018-12-14 14:40:48'),(36,'发送邮件','/mg/v2/notifications/mail/','POST','0','2018-12-27 13:11:20','2018-12-27 13:11:20'),(37,'获取前端权限','/accounts/authorization/','GET','0','2018-12-27 16:28:07','2018-12-27 16:28:07'),(38,'获取镜像仓库信息','/task/v2/task_other/docker_registry/','GET','0','2019-01-14 16:12:58','2019-01-14 16:12:58'),(39,'已发布配置获取','/kerrigan/v1/conf/publish/','GET','0','2019-01-29 16:01:36','2019-01-29 16:01:36'),(40,'钩子提交任务','/task/v2/task/accept/','POST','0','2019-03-18 16:49:01','2019-03-18 16:48:48'),(42,'获取订单','/task/v2/task/list/','GET','0','2019-03-21 10:55:51','2019-03-21 10:55:51'),(43,'超管注册用户','/mg/register/','POST','0','2019-03-21 11:08:50','2019-03-21 11:05:28'),(44,'超管重置MFA','/mg/v2/accounts/reset_mfa/','PUT','0','2019-03-21 11:09:42','2019-03-21 11:09:42'),(45,'超管重置用户密码','/mg/v2/accounts/reset_pw/','PUT','0','2019-03-21 11:10:18','2019-03-21 11:10:18'),(46,'查看系统配置','/mg/v2/sysconfig/settings/','GET','0','2019-03-21 11:11:32','2019-03-21 11:11:32'),(47,'修改系统配置','/mg/v2/sysconfig/settings/','POST','0','2019-03-21 11:12:09','2019-03-21 11:12:09'),(48,'测试邮件和短信','/mg//v2/sysconfig/check/','POST','0','2019-03-21 11:12:40','2019-03-21 11:12:40'),(49,'用户管理所有权限','/mg//v2/accounts/','ALL','0','2019-03-21 11:13:43','2019-03-21 11:13:43'),(50,'发送短信API','/mg/v2/notifications/sms/','POST','0','2019-03-21 11:15:19','2019-03-21 11:15:19'),(51,'发送邮件API','/mg/v2/notifications/mail/','POST','0','2019-03-21 11:15:46','2019-03-21 11:15:46'),(52,'配置中心所有权限-项目要单独赋权','/kerrigan/v1/conf/','ALL','0','2019-03-21 11:40:13','2019-03-21 11:40:13'),(53,'调度任务日志','/task/ws/v1/task/log/','ALL','0','2019-04-12 09:22:39','2019-03-21 11:41:51'),(54,'查看任务详情','/task/v2/task/check/','GET','0','2019-03-21 11:47:15','2019-03-21 11:47:15'),(55,'查看历史任务','/task/v2/task/check_history/','GET','0','2019-03-21 12:09:43','2019-03-21 11:51:44'),(56,'干预调度任务','/task/v2/task/check/','PUT','0','2019-03-21 12:00:17','2019-03-21 11:54:50'),(57,'调度任务重做-终止','/task/v2/task/check/','PATCH','0','2019-04-25 18:00:54','2019-03-21 11:55:35'),(59,'调度任务模板','/task/v2/task_layout/','ALL','0','2019-03-21 11:57:36','2019-03-21 11:57:36'),(60,'调度任务全部终止','/task/v2/task/list/','PUT','0','2019-03-21 12:00:39','2019-03-21 12:00:39'),(61,'资产管理查看主机','/cmdb/v1/cmdb/server/','GET','0','2019-03-21 12:19:58','2019-03-21 12:05:00'),(62,'资产管理-查看主机组','/cmdb/v1/cmdb/server_group/','GET','0','2019-03-21 12:20:04','2019-03-21 12:05:18'),(63,'资产管理-查看审计日志','/cmdb/v1/cmdb/server_log/','GET','0','2019-03-21 12:20:08','2019-03-21 12:05:38'),(64,'数据库优化日志','/task/ws/v1/task/log_data/','ALL','0','2019-04-12 09:23:27','2019-04-12 09:23:27'),(65,'页面任务发布','/task//other/v1/submission/','ALL','0','2019-04-12 09:24:36','2019-04-12 09:24:36'),(66,'任务提交-发布','/task/other/v1/submission/publish/','ALL','0','2019-04-12 09:25:06','2019-04-12 09:25:06'),(67,'任务提交-数据库审计','/task/other/v1/submission/mysql_audit/','ALL','0','2019-04-12 09:25:55','2019-04-12 09:25:55'),(68,'任务提交-数据库优化','/task/other/v1/submission/mysql_opt/','ALL','0','2019-04-12 09:26:24','2019-04-12 09:26:24'),(69,'任务提交-自定义','/task/other/v1/submission/custom_task/','ALL','0','2019-04-12 09:26:54','2019-04-12 09:26:54'),(70,'任务提交-自定义-代理','/task/other/v1/submission/custom_task_proxy/','ALL','0','2019-04-12 09:27:49','2019-04-12 09:27:49'),(71,'任务提交-自定义-json','/task/other/v1/submission/post_task/','ALL','0','2019-04-12 09:28:18','2019-04-12 09:28:18'),(72,'获取有权限资产标签','/task/other/v1/record/tag_auth/','GET','0','2019-04-15 10:33:37','2019-04-15 10:33:37'),(73,'订单审批','/task/v2/task/list/','PATCH','0','2019-04-25 17:27:20','2019-04-25 17:27:20'),(74,'PrometheusWebHooks','/tools/v1/tools/send/prometheus/','POST','0','2019-04-26 17:30:10','2019-04-26 17:30:10'),(75,'任务统计','/task/v2/task/statement/','GET','0','2019-05-21 10:58:25','2019-05-21 10:58:25'),(76,'DNS页面所有权限','/dns/v1/dns/bind/','ALL','0','2019-05-23 09:17:17','2019-05-23 09:17:17'),(77,'DNS查看域名','/dns/v1/dns/bind/domain/','GET','0','2019-05-23 09:17:55','2019-05-23 09:17:55'),(78,'DNS添加域名','/dns/v1/dns/bind/domain/','POST','0','2019-05-23 09:18:20','2019-05-23 09:18:20'),(79,'DNS删除域名','/dns/v1/dns/bind/domain/','DELETE','0','2019-05-23 09:18:48','2019-05-23 09:18:48'),(80,'DNS域名禁用启用','/dns/v1/dns/bind/domain/','PATCH','0','2019-05-23 09:19:10','2019-05-23 09:19:10'),(81,'DNS-API脚本获取域名','/dns/v2/dns/bind/domain/','GET','0','2019-05-23 09:20:04','2019-05-23 09:20:04'),(82,'DNS-API脚本获取区域','/dns/v2/dns/bind/zone/','GET','0','2019-05-23 09:20:39','2019-05-23 09:20:39'),(83,'DNS-区域文件所有权限','/dns/v1/dns/bind/zone/','ALL','0','2019-05-23 09:21:23','2019-05-23 09:21:23'),(84,'DNS-添加解析','/dns/v1/dns/bind/zone/','POST','0','2019-05-23 09:21:58','2019-05-23 09:21:58'),(85,'DNS-查看解析','/dns/v1/dns/bind/zone/','GET','0','2019-05-23 09:22:39','2019-05-23 09:22:39'),(86,'DNS-删除解析','/dns/v1/dns/bind/zone/','DELETE','0','2019-05-23 09:23:02','2019-05-23 09:23:02'),(87,'DNS-修改解析','/dns/v1/dns/bind/zone/','PUT','0','2019-05-23 09:23:38','2019-05-23 09:23:38'),(88,'DNS-解析禁用启用','/dns/v1/dns/bind/zone/','PATCH','0','2019-05-23 09:24:09','2019-05-23 09:24:09'),(89,'DNS-获取配置','/dns/v1/dns/bind/conf/','GET','0','2019-05-23 09:24:57','2019-05-23 09:24:57'),(90,'DNS-查看日志','/dns/v1/dns/bind/log/','GET','0','2019-05-23 09:25:31','2019-05-23 09:25:31'),(91,'CMDB-获取主机','/cmdb2//v1/cmdb/server/','GET','0','2019-05-23 10:02:48','2019-05-23 10:02:48'),(92,'CMDB-添加主机','/cmdb2/v1/cmdb/server/','POST','0','2019-05-23 10:16:29','2019-05-23 10:16:29'),(93,'CMDB-更新主机','/cmdb2/v1/cmdb/server/','PUT','0','2019-05-23 10:16:57','2019-05-23 10:16:57'),(94,'CMDB-删除主机','/cmdb2/v1/cmdb/server/','DELETE','0','2019-05-23 10:17:18','2019-05-23 10:17:18'),(95,'CMDB-查看主机详情','/cmdb2/v1/cmdb/server_detail/','GET','0','2019-05-23 10:22:24','2019-05-23 10:22:24'),(96,'CMDB-获取DB','/cmdb2/v1/cmdb/db/','GET','0','2019-05-23 10:24:11','2019-05-23 10:24:11'),(97,'CMDB-添加DB','/cmdb2/v1/cmdb/db/','POST','0','2019-05-23 10:24:22','2019-05-23 10:24:22'),(98,'CMDB-更新DB','/cmdb2/v1/cmdb/db/','PUT','0','2019-05-23 10:24:46','2019-05-23 10:24:46'),(99,'CMDB-删除DB','/cmdb2/v1/cmdb/db/','DELETE','0','2019-05-23 10:25:02','2019-05-23 10:25:02'),(100,'CMDB-获取标签','/cmdb2/v1/cmdb/tag/','GET','0','2019-05-23 10:25:46','2019-05-23 10:25:46'),(101,'CMDB-添加标签','/cmdb2/v1/cmdb/tag/','POST','0','2019-05-23 10:26:21','2019-05-23 10:26:15'),(102,'CMDB-更新标签','/cmdb2/v1/cmdb/tag/','PUT','0','2019-05-23 10:26:42','2019-05-23 10:26:42'),(103,'CMDB-删除标签','/cmdb2/v1/cmdb/tag/','DELETE','0','2019-05-23 10:26:54','2019-05-23 10:26:54'),(104,'CMDB-主机资产更新','/cmdb2//v1/cmdb/server/asset_update/','POST','0','2019-05-23 10:27:35','2019-05-23 10:27:35'),(105,'CMDB-获取资产配置','/cmdb2/v1/cmdb/asset_configs/','GET','0','2019-05-23 10:28:14','2019-05-23 10:28:14'),(106,'CMDB-添加资产配置','/cmdb2/v1/cmdb/asset_configs/','POST','0','2019-05-23 10:28:27','2019-05-23 10:28:27'),(107,'CMDB-更新资产配置','/cmdb2/v1/cmdb/asset_configs/','PUT','0','2019-05-23 10:28:39','2019-05-23 10:28:39'),(108,'CMDB-删除资产配置','/cmdb2/v1/cmdb/asset_configs/','DELETE','0','2019-05-23 10:28:56','2019-05-23 10:28:56'),(109,'CMDB-拉取云厂商主机信息','/cmdb2//v1/cmdb/asset_configs/handler_update_server/','GET','0','2019-05-23 11:02:32','2019-05-23 11:02:32'); -/*!40000 ALTER TABLE `mg_functions` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_menus` --- - -LOCK TABLES `mg_menus` WRITE; -/*!40000 ALTER TABLE `mg_menus` DISABLE KEYS */; -INSERT INTO `mg_menus` VALUES (1,'home','0'),(2,'_home','0'),(3,'components','0'),(4,'count_to_page','0'),(5,'tables_page','0'),(6,'usermanage','0'),(7,'user','0'),(8,'role','0'),(9,'functions','0'),(10,'menus','0'),(12,'systemmanage','0'),(13,'system','0'),(14,'systemlog','0'),(18,'cron','0'),(19,'cronjobs','0'),(20,'cronlogs','0'),(22,'task_layout','0'),(23,'commandlist','0'),(24,'argslist','0'),(25,'templist','0'),(26,'order','0'),(27,'taskOrderList','0'),(28,'taskuser','0'),(29,'operation_center','0'),(32,'mysqlAudit','0'),(33,'publishApp','0'),(34,'mysqlOptimize','0'),(35,'resourceApplication','0'),(37,'customTasks','0'),(38,'publishConfig','0'),(39,'codeRepository','0'),(40,'dockerRegistry','0'),(41,'cmdb','0'),(42,'asset_server','0'),(43,'log_audit','0'),(46,'tag_mg','0'),(47,'admin_user','0'),(50,'k8s','20'),(51,'project','20'),(52,'app','20'),(53,'project_publish','0'),(54,'publish_list','0'),(55,'statisticaldata','0'),(56,'statisticalImage','0'),(57,'historyTaskList','0'),(58,'asset_db','0'),(59,'config_center','0'),(60,'project_config_list','0'),(61,'my_config_list','0'),(62,'confd','0'),(63,'confd_project','0'),(64,'confd_config','0'),(65,'devopstools','0'),(66,'prometheus_alert','0'),(68,'tagTree','0'),(69,'event_manager','0'),(70,'password_mycrypy','0'),(72,'proxyInfo','0'),(73,'paid_reminder','0'),(74,'project_manager','0'),(75,'postTasks','0'),(76,'taskCenter','0'),(77,'fault_manager','0'),(78,'assetPurchase','0'),(79,'nodeAdd','0'),(80,'customTasksProxy','0'),(85,'web_ssh','0'),(87,'tag_mg','0'),(88,'assetPurchaseALY','0'),(89,'assetPurchaseAWS','0'),(90,'assetPurchaseQcloud','0'),(91,'domain','0'),(92,'domain_name_manage','0'),(93,'domain_name_monitor','0'),(94,'system_user','0'),(95,'asset_config','0'); -/*!40000 ALTER TABLE `mg_menus` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_role_functions` --- - -LOCK TABLES `mg_role_functions` WRITE; -/*!40000 ALTER TABLE `mg_role_functions` DISABLE KEYS */; -/*!40000 ALTER TABLE `mg_role_functions` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_role_menus` --- - -LOCK TABLES `mg_role_menus` WRITE; -/*!40000 ALTER TABLE `mg_role_menus` DISABLE KEYS */; -/*!40000 ALTER TABLE `mg_role_menus` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_roles` --- - -LOCK TABLES `mg_roles` WRITE; -/*!40000 ALTER TABLE `mg_roles` DISABLE KEYS */; -/*!40000 ALTER TABLE `mg_roles` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_roles_components` --- - -LOCK TABLES `mg_roles_components` WRITE; -/*!40000 ALTER TABLE `mg_roles_components` DISABLE KEYS */; -/*!40000 ALTER TABLE `mg_roles_components` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_user_roles` --- - -LOCK TABLES `mg_user_roles` WRITE; -/*!40000 ALTER TABLE `mg_user_roles` DISABLE KEYS */; -/*!40000 ALTER TABLE `mg_user_roles` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `mg_users` --- - -LOCK TABLES `mg_users` WRITE; -/*!40000 ALTER TABLE `mg_users` DISABLE KEYS */; -INSERT INTO `mg_users` VALUES (1,'admin','66e7bcb387a66f2bf98ad62de7b8a82c','admin','191715030@qq.com','11111111111','','','admin','','0','0','180.168.11.84','2019-05-24 10:39:29','2017-12-21 14:26:04'); -/*!40000 ALTER TABLE `mg_users` ENABLE KEYS */; -UNLOCK TABLES; - --- --- Dumping data for table `operation_record` --- - -LOCK TABLES `operation_record` WRITE; -/*!40000 ALTER TABLE `operation_record` DISABLE KEYS */; -/*!40000 ALTER TABLE `operation_record` ENABLE KEYS */; -UNLOCK TABLES; -/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; - -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; - --- Dump completed on 2019-05-24 10:39:42 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 16c8be4..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -do_mg: - restart: unless-stopped - image: do_mg_image - volumes: - - /var/log/supervisor/:/var/log/supervisor/ - - /sys/fs/cgroup:/sys/fs/cgroup - ports: - - "8010:80" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..5cd9c19 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,16 @@ +version: "3.8" +networks: + codo: +services: + codo-admin: + env_file: + - ./env.sh + restart: unless-stopped + image: registry.cn-hangzhou.aliyuncs.com/sourcegarden/opendevops-admin:alpine-0.3.0 + volumes: + - /var/log/supervisor/:/var/log/supervisor/ + - /sys/fs/cgroup:/sys/fs/cgroup + ports: + - "8010:80" + networks: + - codo \ No newline at end of file diff --git a/docker/env.sh b/docker/env.sh new file mode 100644 index 0000000..b50a158 --- /dev/null +++ b/docker/env.sh @@ -0,0 +1,76 @@ +# 设置MYSQL root用户密码,若你只打算启动mysql,那么此变量是必须的,其余的都可以不需要 +MYSQL_ROOT_PASSWORD="m9uSFL7duAVXfeAwGUSGroot" + +#本机的IP地址 +LOCALHOST_IP="127.0.0.1" + +#设置你的MYSQL密码 +MYSQL_PASSWORD="${MYSQL_ROOT_PASSWORD}" + +### 设置你的redis密码 +REDIS_PASSWORD="cWCVKJ7ZHUK12mVbivUf" + +### RabbitMQ用户密码信息 +MQ_USER="ss" +MQ_PASSWORD="5Q2ajBHRT2lFJjnvaU0g" + +### 管理后端地址 +mg_domain="codo-mg" + +### 定时任务地址,目前只启动一个进程,不用域名,直接IP即可 +cron_domain="codo-cron" + +### 任务系统地址 +task_domain="codo-task" + +### CMDB系统地址 +cmdb_domain="codo-cmdb2" + +### 运维工具地址 +tools_domain="codo-tools" + + +### 域名管理地址 +dns_domain="codo-dns" + + +### 配置中心域名 +kerrigan_domain="codo-kerrigan" + +### 前端地址,也就是你的访问地址 +front_domain="codo-front" + +### api网关地址 +api_gw_url="codo-gw" + + +#codo-admin用到的cookie和token,可留默认 +cookie_secret="nJ2oZis0V/xlArY2rzpIE6ioC9/KlqR2fd59sD=UXZJ=3OeROB" +# 这里codo-admin和gw网关都会用到,一定要修改。可生成随意字符 +token_secret="pXFb4i%*834gfdh963df718iodGq4dsafsdadg7yI6ImF1999aaG7" + + +##如果要进行读写分离,Master-slave主从请自行建立,一般情况下都是只用一个数据库就可以了 +# 写数据库 +DEFAULT_DB_DBHOST="codo-mysql" +DEFAULT_DB_DBPORT='3306' +DEFAULT_DB_DBUSER='root' +DEFAULT_DB_DBPWD=${MYSQL_PASSWORD} +#DEFAULT_DB_DBNAME=${mysql_database} + +# 读数据库 +READONLY_DB_DBHOST='codo-mysql' +READONLY_DB_DBPORT='3306' +READONLY_DB_DBUSER='root' +READONLY_DB_DBPWD=${MYSQL_PASSWORD} +#READONLY_DB_DBNAME=${mysql_database} + +# 消息队列 +DEFAULT_MQ_ADDR='codo-mq' +DEFAULT_MQ_USER=${MQ_USER} +DEFAULT_MQ_PWD=${MQ_PASSWORD} + +# 缓存 +DEFAULT_REDIS_HOST='codo-redis' +DEFAULT_REDIS_PORT=6379 +DEFAULT_REDIS_PASSWORD=${REDIS_PASSWORD} \ No newline at end of file diff --git a/doc/nginx_ops.conf b/docker/nginx_ops.conf similarity index 100% rename from doc/nginx_ops.conf rename to docker/nginx_ops.conf diff --git a/docker/prestart.sh b/docker/prestart.sh new file mode 100644 index 0000000..4e1b714 --- /dev/null +++ b/docker/prestart.sh @@ -0,0 +1,24 @@ +#!/bin/sh +cd /var/www/codo-admin/ + + #管理后端-admin + echo -e "\033[32m [INFO]: 开始修改各项目的配置文件 \033[0m" + source /opt/codo/env.sh + sed -i "s#cookie_secret = .*#cookie_secret = '${cookie_secret}'#g" codo-admin-settings.py + sed -i "s#token_secret = .*#token_secret = '${token_secret}'#g" codo-admin-settings.py + DEFAULT_DB_DBNAME='codo_admin' + sed -i "s#DEFAULT_DB_DBHOST = .*#DEFAULT_DB_DBHOST = os.getenv('DEFAULT_DB_DBHOST', '${DEFAULT_DB_DBHOST}')#g" codo-admin-settings.py + sed -i "s#DEFAULT_DB_DBPORT = .*#DEFAULT_DB_DBPORT = os.getenv('DEFAULT_DB_DBPORT', '${DEFAULT_DB_DBPORT}')#g" codo-admin-settings.py + sed -i "s#DEFAULT_DB_DBUSER = .*#DEFAULT_DB_DBUSER = os.getenv('DEFAULT_DB_DBUSER', '${DEFAULT_DB_DBUSER}')#g" codo-admin-settings.py + sed -i "s#DEFAULT_DB_DBPWD = .*#DEFAULT_DB_DBPWD = os.getenv('DEFAULT_DB_DBPWD', '${DEFAULT_DB_DBPWD}')#g" codo-admin-settings.py + sed -i "s#DEFAULT_DB_DBNAME = .*#DEFAULT_DB_DBNAME = os.getenv('DEFAULT_DB_DBNAME', '${DEFAULT_DB_DBNAME}')#g" codo-admin-settings.py + sed -i "s#READONLY_DB_DBHOST = .*#READONLY_DB_DBHOST = os.getenv('READONLY_DB_DBHOST', '${READONLY_DB_DBHOST}')#g" codo-admin-settings.py + sed -i "s#READONLY_DB_DBPORT = .*#READONLY_DB_DBPORT = os.getenv('READONLY_DB_DBPORT', '${READONLY_DB_DBPORT}')#g" codo-admin-settings.py + sed -i "s#READONLY_DB_DBUSER = .*#READONLY_DB_DBUSER = os.getenv('READONLY_DB_DBUSER', '${READONLY_DB_DBUSER}')#g" codo-admin-settings.py + sed -i "s#READONLY_DB_DBPWD = .*#READONLY_DB_DBPWD = os.getenv('READONLY_DB_DBPWD', '${READONLY_DB_DBPWD}')#g" codo-admin-settings.py + sed -i "s#READONLY_DB_DBNAME = .*#READONLY_DB_DBNAME = os.getenv('READONLY_DB_DBNAME', '${DEFAULT_DB_DBNAME}')#g" codo-admin-settings.py + sed -i "s#DEFAULT_REDIS_HOST = .*#DEFAULT_REDIS_HOST = os.getenv('DEFAULT_REDIS_HOST', '${DEFAULT_REDIS_HOST}')#g" codo-admin-settings.py + sed -i "s#DEFAULT_REDIS_PORT = .*#DEFAULT_REDIS_PORT = os.getenv('DEFAULT_REDIS_PORT', '${DEFAULT_REDIS_PORT}')#g" codo-admin-settings.py + sed -i "s#DEFAULT_REDIS_PASSWORD = .*#DEFAULT_REDIS_PASSWORD = os.getenv('DEFAULT_REDIS_PASSWORD', '${DEFAULT_REDIS_PASSWORD}')#g" codo-admin-settings.py + +#python3 /var/www/kerrigan/db_sync.py \ No newline at end of file diff --git a/doc/supervisor_ops.conf b/docker/supervisor_ops.conf similarity index 73% rename from doc/supervisor_ops.conf rename to docker/supervisor_ops.conf index 29a15c2..520a4c6 100644 --- a/doc/supervisor_ops.conf +++ b/docker/supervisor_ops.conf @@ -2,7 +2,19 @@ nodaemon=true [group:do_admin,] -programs=mg,sub_log +programs=mg-prestart,mg,sub_log + +[program:mg-prestart] +command=sh prestart.sh +directory=/var/www/codo-admin +user=root +autostart = true +autorestart=false +redirect_stderr=true +stdout_logfile=/var/log/supervisor/mg-prestart.log +loglevel=info +logfile_maxbytes=10MB +logfile_backups=1 [program:mg] command=python3 startup.py --service=mg --port=98%(process_num)02d diff --git a/doc/requirements.txt b/requirements.txt similarity index 100% rename from doc/requirements.txt rename to requirements.txt From 68d2c0bbf70ef71217ea8cf6197ace3792a3dcdf Mon Sep 17 00:00:00 2001 From: Heaven Date: Fri, 12 Jun 2020 21:59:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=89=93=E5=8C=85?= =?UTF-8?q?=E9=95=9C=E5=83=8F,=E5=B0=86=E7=8E=AF=E5=A2=83=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=85=A8=E9=83=A8=E8=BD=AC=E4=B8=BA=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=86=85=E6=9D=A5=E6=93=8D=E4=BD=9C=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 6 +- codo_admin_beta0.3.sql | 130 +++++++++++++++++++++++++++++++++++++ docker/docker-compose.yml | 16 ----- docker/env.sh | 76 ---------------------- docker/nginx_ops.conf | 4 +- docker/prestart.sh | 61 ++++++++++++----- docker/supervisor_ops.conf | 2 +- 7 files changed, 179 insertions(+), 116 deletions(-) create mode 100644 codo_admin_beta0.3.sql delete mode 100644 docker/docker-compose.yml delete mode 100644 docker/env.sh diff --git a/Dockerfile b/Dockerfile index 56f20e5..ed46887 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,11 +3,9 @@ FROM registry.cn-hangzhou.aliyuncs.com/sourcegarden/python:centos7-3.6 RUN mkdir -p /var/www/ ADD . /var/www/codo-admin/ -RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r /var/www/codo-admin/doc/requirements.txt +RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r /var/www/codo-admin/requirements.txt -#VOLUME /var/log/ - -COPY docker/nginx_ops.conf /etc/nginx/conf.d/default.conf +COPY docker/nginx_ops.conf /etc/nginx/conf.d/codo-admin.conf COPY docker/supervisor_ops.conf /etc/supervisord.conf EXPOSE 80 diff --git a/codo_admin_beta0.3.sql b/codo_admin_beta0.3.sql new file mode 100644 index 0000000..ed79cf5 --- /dev/null +++ b/codo_admin_beta0.3.sql @@ -0,0 +1,130 @@ +-- MySQL dump 10.14 Distrib 5.5.60-MariaDB, for Linux (x86_64) +-- +-- Host: 127.0.0.1 Database: codo_admin +-- ------------------------------------------------------ +-- Server version 5.7.26 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Dumping data for table `mg_app_settings` +-- + +use codo_admin; + +LOCK TABLES `mg_app_settings` WRITE; +/*!40000 ALTER TABLE `mg_app_settings` DISABLE KEYS */; +/*!40000 ALTER TABLE `mg_app_settings` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_components` +-- + +LOCK TABLES `mg_components` WRITE; +/*!40000 ALTER TABLE `mg_components` DISABLE KEYS */; +INSERT INTO `mg_components` VALUES (2,'edit_button','0'),(3,'publish_button','0'),(8,'reset_mfa_btn','0'),(9,'reset_pwd_btn','0'),(10,'new_user_btn','0'),(12,'get_token_btn','0'),(13,'web_ssh_btn','0'),(14,'asset_error_log','0'); +/*!40000 ALTER TABLE `mg_components` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_functions` +-- + +LOCK TABLES `mg_functions` WRITE; +/*!40000 ALTER TABLE `mg_functions` DISABLE KEYS */; +INSERT INTO `mg_functions` VALUES (6,'ss','/login/','ALL','10','2018-03-21 10:29:14','2018-03-20 18:35:24'),(9,'管理员','/','ALL','0','2018-03-21 14:04:59','2018-03-21 14:04:59'),(10,'任务管理员','/task/v2/task/','ALL','0','2019-03-21 10:57:54','2018-03-22 10:09:10'),(12,'修改密码','/mg/v2/accounts/password/','PATCH','0','2019-03-21 11:07:20','2018-03-22 16:27:12'),(15,'提交任务','/task/v2/task/accept/','POST','0','2019-03-21 10:57:29','2018-06-08 09:26:00'),(16,'获取CSRF','/task/v2/task/accept/','GET','0','2018-12-27 13:16:41','2018-06-08 09:26:51'),(33,'发布配置','/task/v2/task_other/publish_cd/','GET','0','2018-12-05 09:59:48','2018-12-05 09:37:24'),(35,'系统用户获取','/mg/v2/accounts/','GET','0','2018-12-14 14:44:51','2018-12-14 14:40:48'),(36,'发送邮件','/mg/v2/notifications/mail/','POST','0','2018-12-27 13:11:20','2018-12-27 13:11:20'),(37,'获取前端权限','/accounts/authorization/','GET','0','2018-12-27 16:28:07','2018-12-27 16:28:07'),(38,'获取镜像仓库信息','/task/v2/task_other/docker_registry/','GET','0','2019-01-14 16:12:58','2019-01-14 16:12:58'),(39,'已发布配置获取','/kerrigan/v1/conf/publish/','GET','0','2019-01-29 16:01:36','2019-01-29 16:01:36'),(40,'钩子提交任务','/task/v2/task/accept/','POST','0','2019-03-18 16:49:01','2019-03-18 16:48:48'),(42,'获取订单','/task/v2/task/list/','GET','0','2019-03-21 10:55:51','2019-03-21 10:55:51'),(43,'超管注册用户','/mg/register/','POST','0','2019-03-21 11:08:50','2019-03-21 11:05:28'),(44,'超管重置MFA','/mg/v2/accounts/reset_mfa/','PUT','0','2019-03-21 11:09:42','2019-03-21 11:09:42'),(45,'超管重置用户密码','/mg/v2/accounts/reset_pw/','PUT','0','2019-03-21 11:10:18','2019-03-21 11:10:18'),(46,'查看系统配置','/mg/v2/sysconfig/settings/','GET','0','2019-03-21 11:11:32','2019-03-21 11:11:32'),(47,'修改系统配置','/mg/v2/sysconfig/settings/','POST','0','2019-03-21 11:12:09','2019-03-21 11:12:09'),(48,'测试邮件和短信','/mg//v2/sysconfig/check/','POST','0','2019-03-21 11:12:40','2019-03-21 11:12:40'),(49,'用户管理所有权限','/mg//v2/accounts/','ALL','0','2019-03-21 11:13:43','2019-03-21 11:13:43'),(50,'发送短信API','/mg/v2/notifications/sms/','POST','0','2019-03-21 11:15:19','2019-03-21 11:15:19'),(51,'发送邮件API','/mg/v2/notifications/mail/','POST','0','2019-03-21 11:15:46','2019-03-21 11:15:46'),(52,'配置中心所有权限-项目要单独赋权','/kerrigan/v1/conf/','ALL','0','2019-03-21 11:40:13','2019-03-21 11:40:13'),(53,'调度任务日志','/task/ws/v1/task/log/','ALL','0','2019-04-12 09:22:39','2019-03-21 11:41:51'),(54,'查看任务详情','/task/v2/task/check/','GET','0','2019-03-21 11:47:15','2019-03-21 11:47:15'),(55,'查看历史任务','/task/v2/task/check_history/','GET','0','2019-03-21 12:09:43','2019-03-21 11:51:44'),(56,'干预调度任务','/task/v2/task/check/','PUT','0','2019-03-21 12:00:17','2019-03-21 11:54:50'),(57,'调度任务重做-终止','/task/v2/task/check/','PATCH','0','2019-04-25 18:00:54','2019-03-21 11:55:35'),(59,'调度任务模板','/task/v2/task_layout/','ALL','0','2019-03-21 11:57:36','2019-03-21 11:57:36'),(60,'调度任务全部终止','/task/v2/task/list/','PUT','0','2019-03-21 12:00:39','2019-03-21 12:00:39'),(61,'资产管理查看主机','/cmdb/v1/cmdb/server/','GET','0','2019-03-21 12:19:58','2019-03-21 12:05:00'),(62,'资产管理-查看主机组','/cmdb/v1/cmdb/server_group/','GET','0','2019-03-21 12:20:04','2019-03-21 12:05:18'),(63,'资产管理-查看审计日志','/cmdb/v1/cmdb/server_log/','GET','0','2019-03-21 12:20:08','2019-03-21 12:05:38'),(64,'数据库优化日志','/task/ws/v1/task/log_data/','ALL','0','2019-04-12 09:23:27','2019-04-12 09:23:27'),(65,'页面任务发布','/task//other/v1/submission/','ALL','0','2019-04-12 09:24:36','2019-04-12 09:24:36'),(66,'任务提交-发布','/task/other/v1/submission/publish/','ALL','0','2019-04-12 09:25:06','2019-04-12 09:25:06'),(67,'任务提交-数据库审计','/task/other/v1/submission/mysql_audit/','ALL','0','2019-04-12 09:25:55','2019-04-12 09:25:55'),(68,'任务提交-数据库优化','/task/other/v1/submission/mysql_opt/','ALL','0','2019-04-12 09:26:24','2019-04-12 09:26:24'),(69,'任务提交-自定义','/task/other/v1/submission/custom_task/','ALL','0','2019-04-12 09:26:54','2019-04-12 09:26:54'),(70,'任务提交-自定义-代理','/task/other/v1/submission/custom_task_proxy/','ALL','0','2019-04-12 09:27:49','2019-04-12 09:27:49'),(71,'任务提交-自定义-json','/task/other/v1/submission/post_task/','ALL','0','2019-04-12 09:28:18','2019-04-12 09:28:18'),(72,'获取有权限资产标签','/task/other/v1/record/tag_auth/','GET','0','2019-04-15 10:33:37','2019-04-15 10:33:37'),(73,'订单审批','/task/v2/task/list/','PATCH','0','2019-04-25 17:27:20','2019-04-25 17:27:20'),(74,'PrometheusWebHooks','/tools/v1/tools/send/prometheus/','POST','0','2019-04-26 17:30:10','2019-04-26 17:30:10'),(75,'任务统计','/task/v2/task/statement/','GET','0','2019-05-21 10:58:25','2019-05-21 10:58:25'),(76,'DNS页面所有权限','/dns/v1/dns/bind/','ALL','0','2019-05-23 09:17:17','2019-05-23 09:17:17'),(77,'DNS查看域名','/dns/v1/dns/bind/domain/','GET','0','2019-05-23 09:17:55','2019-05-23 09:17:55'),(78,'DNS添加域名','/dns/v1/dns/bind/domain/','POST','0','2019-05-23 09:18:20','2019-05-23 09:18:20'),(79,'DNS删除域名','/dns/v1/dns/bind/domain/','DELETE','0','2019-05-23 09:18:48','2019-05-23 09:18:48'),(80,'DNS域名禁用启用','/dns/v1/dns/bind/domain/','PATCH','0','2019-05-23 09:19:10','2019-05-23 09:19:10'),(81,'DNS-API脚本获取域名','/dns/v2/dns/bind/domain/','GET','0','2019-05-23 09:20:04','2019-05-23 09:20:04'),(82,'DNS-API脚本获取区域','/dns/v2/dns/bind/zone/','GET','0','2019-05-23 09:20:39','2019-05-23 09:20:39'),(83,'DNS-区域文件所有权限','/dns/v1/dns/bind/zone/','ALL','0','2019-05-23 09:21:23','2019-05-23 09:21:23'),(84,'DNS-添加解析','/dns/v1/dns/bind/zone/','POST','0','2019-05-23 09:21:58','2019-05-23 09:21:58'),(85,'DNS-查看解析','/dns/v1/dns/bind/zone/','GET','0','2019-05-23 09:22:39','2019-05-23 09:22:39'),(86,'DNS-删除解析','/dns/v1/dns/bind/zone/','DELETE','0','2019-05-23 09:23:02','2019-05-23 09:23:02'),(87,'DNS-修改解析','/dns/v1/dns/bind/zone/','PUT','0','2019-05-23 09:23:38','2019-05-23 09:23:38'),(88,'DNS-解析禁用启用','/dns/v1/dns/bind/zone/','PATCH','0','2019-05-23 09:24:09','2019-05-23 09:24:09'),(89,'DNS-获取配置','/dns/v1/dns/bind/conf/','GET','0','2019-05-23 09:24:57','2019-05-23 09:24:57'),(90,'DNS-查看日志','/dns/v1/dns/bind/log/','GET','0','2019-05-23 09:25:31','2019-05-23 09:25:31'),(91,'CMDB-获取主机','/cmdb2//v1/cmdb/server/','GET','0','2019-05-23 10:02:48','2019-05-23 10:02:48'),(92,'CMDB-添加主机','/cmdb2/v1/cmdb/server/','POST','0','2019-05-23 10:16:29','2019-05-23 10:16:29'),(93,'CMDB-更新主机','/cmdb2/v1/cmdb/server/','PUT','0','2019-05-23 10:16:57','2019-05-23 10:16:57'),(94,'CMDB-删除主机','/cmdb2/v1/cmdb/server/','DELETE','0','2019-05-23 10:17:18','2019-05-23 10:17:18'),(95,'CMDB-查看主机详情','/cmdb2/v1/cmdb/server_detail/','GET','0','2019-05-23 10:22:24','2019-05-23 10:22:24'),(96,'CMDB-获取DB','/cmdb2/v1/cmdb/db/','GET','0','2019-05-23 10:24:11','2019-05-23 10:24:11'),(97,'CMDB-添加DB','/cmdb2/v1/cmdb/db/','POST','0','2019-05-23 10:24:22','2019-05-23 10:24:22'),(98,'CMDB-更新DB','/cmdb2/v1/cmdb/db/','PUT','0','2019-05-23 10:24:46','2019-05-23 10:24:46'),(99,'CMDB-删除DB','/cmdb2/v1/cmdb/db/','DELETE','0','2019-05-23 10:25:02','2019-05-23 10:25:02'),(100,'CMDB-获取标签','/cmdb2/v1/cmdb/tag/','GET','0','2019-05-23 10:25:46','2019-05-23 10:25:46'),(101,'CMDB-添加标签','/cmdb2/v1/cmdb/tag/','POST','0','2019-05-23 10:26:21','2019-05-23 10:26:15'),(102,'CMDB-更新标签','/cmdb2/v1/cmdb/tag/','PUT','0','2019-05-23 10:26:42','2019-05-23 10:26:42'),(103,'CMDB-删除标签','/cmdb2/v1/cmdb/tag/','DELETE','0','2019-05-23 10:26:54','2019-05-23 10:26:54'),(104,'CMDB-主机资产更新','/cmdb2//v1/cmdb/server/asset_update/','POST','0','2019-05-23 10:27:35','2019-05-23 10:27:35'),(105,'CMDB-获取资产配置','/cmdb2/v1/cmdb/asset_configs/','GET','0','2019-05-23 10:28:14','2019-05-23 10:28:14'),(106,'CMDB-添加资产配置','/cmdb2/v1/cmdb/asset_configs/','POST','0','2019-05-23 10:28:27','2019-05-23 10:28:27'),(107,'CMDB-更新资产配置','/cmdb2/v1/cmdb/asset_configs/','PUT','0','2019-05-23 10:28:39','2019-05-23 10:28:39'),(108,'CMDB-删除资产配置','/cmdb2/v1/cmdb/asset_configs/','DELETE','0','2019-05-23 10:28:56','2019-05-23 10:28:56'),(109,'CMDB-拉取云厂商主机信息','/cmdb2//v1/cmdb/asset_configs/handler_update_server/','GET','0','2019-05-23 11:02:32','2019-05-23 11:02:32'); +/*!40000 ALTER TABLE `mg_functions` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_menus` +-- + +LOCK TABLES `mg_menus` WRITE; +/*!40000 ALTER TABLE `mg_menus` DISABLE KEYS */; +INSERT INTO `mg_menus` VALUES (1,'home','0'),(2,'_home','0'),(3,'components','0'),(4,'count_to_page','0'),(5,'tables_page','0'),(6,'usermanage','0'),(7,'user','0'),(8,'role','0'),(9,'functions','0'),(10,'menus','0'),(12,'systemmanage','0'),(13,'system','0'),(14,'systemlog','0'),(18,'cron','0'),(19,'cronjobs','0'),(20,'cronlogs','0'),(22,'task_layout','0'),(23,'commandlist','0'),(24,'argslist','0'),(25,'templist','0'),(26,'order','0'),(27,'taskOrderList','0'),(28,'taskuser','0'),(29,'operation_center','0'),(32,'mysqlAudit','0'),(33,'publishApp','0'),(34,'mysqlOptimize','0'),(35,'resourceApplication','0'),(37,'customTasks','0'),(38,'publishConfig','0'),(39,'codeRepository','0'),(40,'dockerRegistry','0'),(41,'cmdb','0'),(42,'asset_server','0'),(43,'log_audit','0'),(46,'tag_mg','0'),(47,'admin_user','0'),(50,'k8s','20'),(51,'project','20'),(52,'app','20'),(53,'project_publish','0'),(54,'publish_list','0'),(55,'statisticaldata','0'),(56,'statisticalImage','0'),(57,'historyTaskList','0'),(58,'asset_db','0'),(59,'config_center','0'),(60,'project_config_list','0'),(61,'my_config_list','0'),(62,'confd','0'),(63,'confd_project','0'),(64,'confd_config','0'),(65,'devopstools','0'),(66,'prometheus_alert','0'),(68,'tagTree','0'),(69,'event_manager','0'),(70,'password_mycrypy','0'),(72,'proxyInfo','0'),(73,'paid_reminder','0'),(74,'project_manager','0'),(75,'postTasks','0'),(76,'taskCenter','0'),(77,'fault_manager','0'),(78,'assetPurchase','0'),(79,'nodeAdd','0'),(80,'customTasksProxy','0'),(85,'web_ssh','0'),(87,'tag_mg','0'),(88,'assetPurchaseALY','0'),(89,'assetPurchaseAWS','0'),(90,'assetPurchaseQcloud','0'),(91,'domain','0'),(92,'domain_name_manage','0'),(93,'domain_name_monitor','0'),(94,'system_user','0'),(95,'asset_config','0'); +/*!40000 ALTER TABLE `mg_menus` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_role_functions` +-- + +LOCK TABLES `mg_role_functions` WRITE; +/*!40000 ALTER TABLE `mg_role_functions` DISABLE KEYS */; +/*!40000 ALTER TABLE `mg_role_functions` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_role_menus` +-- + +LOCK TABLES `mg_role_menus` WRITE; +/*!40000 ALTER TABLE `mg_role_menus` DISABLE KEYS */; +/*!40000 ALTER TABLE `mg_role_menus` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_roles` +-- + +LOCK TABLES `mg_roles` WRITE; +/*!40000 ALTER TABLE `mg_roles` DISABLE KEYS */; +/*!40000 ALTER TABLE `mg_roles` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_roles_components` +-- + +LOCK TABLES `mg_roles_components` WRITE; +/*!40000 ALTER TABLE `mg_roles_components` DISABLE KEYS */; +/*!40000 ALTER TABLE `mg_roles_components` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_user_roles` +-- + +LOCK TABLES `mg_user_roles` WRITE; +/*!40000 ALTER TABLE `mg_user_roles` DISABLE KEYS */; +/*!40000 ALTER TABLE `mg_user_roles` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `mg_users` +-- + +LOCK TABLES `mg_users` WRITE; +/*!40000 ALTER TABLE `mg_users` DISABLE KEYS */; +INSERT INTO `mg_users` VALUES (1,'admin','66e7bcb387a66f2bf98ad62de7b8a82c','admin','191715030@qq.com','11111111111','','','admin','','0','0','180.168.11.84','2019-05-24 10:39:29','2017-12-21 14:26:04'); +/*!40000 ALTER TABLE `mg_users` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping data for table `operation_record` +-- + +LOCK TABLES `operation_record` WRITE; +/*!40000 ALTER TABLE `operation_record` DISABLE KEYS */; +/*!40000 ALTER TABLE `operation_record` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2019-05-24 10:39:42 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml deleted file mode 100644 index 5cd9c19..0000000 --- a/docker/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: "3.8" -networks: - codo: -services: - codo-admin: - env_file: - - ./env.sh - restart: unless-stopped - image: registry.cn-hangzhou.aliyuncs.com/sourcegarden/opendevops-admin:alpine-0.3.0 - volumes: - - /var/log/supervisor/:/var/log/supervisor/ - - /sys/fs/cgroup:/sys/fs/cgroup - ports: - - "8010:80" - networks: - - codo \ No newline at end of file diff --git a/docker/env.sh b/docker/env.sh deleted file mode 100644 index b50a158..0000000 --- a/docker/env.sh +++ /dev/null @@ -1,76 +0,0 @@ -# 设置MYSQL root用户密码,若你只打算启动mysql,那么此变量是必须的,其余的都可以不需要 -MYSQL_ROOT_PASSWORD="m9uSFL7duAVXfeAwGUSGroot" - -#本机的IP地址 -LOCALHOST_IP="127.0.0.1" - -#设置你的MYSQL密码 -MYSQL_PASSWORD="${MYSQL_ROOT_PASSWORD}" - -### 设置你的redis密码 -REDIS_PASSWORD="cWCVKJ7ZHUK12mVbivUf" - -### RabbitMQ用户密码信息 -MQ_USER="ss" -MQ_PASSWORD="5Q2ajBHRT2lFJjnvaU0g" - -### 管理后端地址 -mg_domain="codo-mg" - -### 定时任务地址,目前只启动一个进程,不用域名,直接IP即可 -cron_domain="codo-cron" - -### 任务系统地址 -task_domain="codo-task" - -### CMDB系统地址 -cmdb_domain="codo-cmdb2" - -### 运维工具地址 -tools_domain="codo-tools" - - -### 域名管理地址 -dns_domain="codo-dns" - - -### 配置中心域名 -kerrigan_domain="codo-kerrigan" - -### 前端地址,也就是你的访问地址 -front_domain="codo-front" - -### api网关地址 -api_gw_url="codo-gw" - - -#codo-admin用到的cookie和token,可留默认 -cookie_secret="nJ2oZis0V/xlArY2rzpIE6ioC9/KlqR2fd59sD=UXZJ=3OeROB" -# 这里codo-admin和gw网关都会用到,一定要修改。可生成随意字符 -token_secret="pXFb4i%*834gfdh963df718iodGq4dsafsdadg7yI6ImF1999aaG7" - - -##如果要进行读写分离,Master-slave主从请自行建立,一般情况下都是只用一个数据库就可以了 -# 写数据库 -DEFAULT_DB_DBHOST="codo-mysql" -DEFAULT_DB_DBPORT='3306' -DEFAULT_DB_DBUSER='root' -DEFAULT_DB_DBPWD=${MYSQL_PASSWORD} -#DEFAULT_DB_DBNAME=${mysql_database} - -# 读数据库 -READONLY_DB_DBHOST='codo-mysql' -READONLY_DB_DBPORT='3306' -READONLY_DB_DBUSER='root' -READONLY_DB_DBPWD=${MYSQL_PASSWORD} -#READONLY_DB_DBNAME=${mysql_database} - -# 消息队列 -DEFAULT_MQ_ADDR='codo-mq' -DEFAULT_MQ_USER=${MQ_USER} -DEFAULT_MQ_PWD=${MQ_PASSWORD} - -# 缓存 -DEFAULT_REDIS_HOST='codo-redis' -DEFAULT_REDIS_PORT=6379 -DEFAULT_REDIS_PASSWORD=${REDIS_PASSWORD} \ No newline at end of file diff --git a/docker/nginx_ops.conf b/docker/nginx_ops.conf index c3b7e78..5229432 100644 --- a/docker/nginx_ops.conf +++ b/docker/nginx_ops.conf @@ -1,4 +1,4 @@ -upstream codo-admin{ +upstream codo-admin-nginx{ server 127.0.0.1:9800; server 127.0.0.1:9801; server 127.0.0.1:9802; @@ -17,6 +17,6 @@ server proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_set_header  Cookie $http_cookie; - proxy_pass http://codo-admin; + proxy_pass http://codo-admin-nginx; } } \ No newline at end of file diff --git a/docker/prestart.sh b/docker/prestart.sh index 4e1b714..d1500ae 100644 --- a/docker/prestart.sh +++ b/docker/prestart.sh @@ -3,22 +3,49 @@ cd /var/www/codo-admin/ #管理后端-admin echo -e "\033[32m [INFO]: 开始修改各项目的配置文件 \033[0m" - source /opt/codo/env.sh - sed -i "s#cookie_secret = .*#cookie_secret = '${cookie_secret}'#g" codo-admin-settings.py - sed -i "s#token_secret = .*#token_secret = '${token_secret}'#g" codo-admin-settings.py + sed -i "s#cookie_secret = .*#cookie_secret = '${cookie_secret}'#g" settings.py + sed -i "s#token_secret = .*#token_secret = '${token_secret}'#g" settings.py DEFAULT_DB_DBNAME='codo_admin' - sed -i "s#DEFAULT_DB_DBHOST = .*#DEFAULT_DB_DBHOST = os.getenv('DEFAULT_DB_DBHOST', '${DEFAULT_DB_DBHOST}')#g" codo-admin-settings.py - sed -i "s#DEFAULT_DB_DBPORT = .*#DEFAULT_DB_DBPORT = os.getenv('DEFAULT_DB_DBPORT', '${DEFAULT_DB_DBPORT}')#g" codo-admin-settings.py - sed -i "s#DEFAULT_DB_DBUSER = .*#DEFAULT_DB_DBUSER = os.getenv('DEFAULT_DB_DBUSER', '${DEFAULT_DB_DBUSER}')#g" codo-admin-settings.py - sed -i "s#DEFAULT_DB_DBPWD = .*#DEFAULT_DB_DBPWD = os.getenv('DEFAULT_DB_DBPWD', '${DEFAULT_DB_DBPWD}')#g" codo-admin-settings.py - sed -i "s#DEFAULT_DB_DBNAME = .*#DEFAULT_DB_DBNAME = os.getenv('DEFAULT_DB_DBNAME', '${DEFAULT_DB_DBNAME}')#g" codo-admin-settings.py - sed -i "s#READONLY_DB_DBHOST = .*#READONLY_DB_DBHOST = os.getenv('READONLY_DB_DBHOST', '${READONLY_DB_DBHOST}')#g" codo-admin-settings.py - sed -i "s#READONLY_DB_DBPORT = .*#READONLY_DB_DBPORT = os.getenv('READONLY_DB_DBPORT', '${READONLY_DB_DBPORT}')#g" codo-admin-settings.py - sed -i "s#READONLY_DB_DBUSER = .*#READONLY_DB_DBUSER = os.getenv('READONLY_DB_DBUSER', '${READONLY_DB_DBUSER}')#g" codo-admin-settings.py - sed -i "s#READONLY_DB_DBPWD = .*#READONLY_DB_DBPWD = os.getenv('READONLY_DB_DBPWD', '${READONLY_DB_DBPWD}')#g" codo-admin-settings.py - sed -i "s#READONLY_DB_DBNAME = .*#READONLY_DB_DBNAME = os.getenv('READONLY_DB_DBNAME', '${DEFAULT_DB_DBNAME}')#g" codo-admin-settings.py - sed -i "s#DEFAULT_REDIS_HOST = .*#DEFAULT_REDIS_HOST = os.getenv('DEFAULT_REDIS_HOST', '${DEFAULT_REDIS_HOST}')#g" codo-admin-settings.py - sed -i "s#DEFAULT_REDIS_PORT = .*#DEFAULT_REDIS_PORT = os.getenv('DEFAULT_REDIS_PORT', '${DEFAULT_REDIS_PORT}')#g" codo-admin-settings.py - sed -i "s#DEFAULT_REDIS_PASSWORD = .*#DEFAULT_REDIS_PASSWORD = os.getenv('DEFAULT_REDIS_PASSWORD', '${DEFAULT_REDIS_PASSWORD}')#g" codo-admin-settings.py + sed -i "s#DEFAULT_DB_DBHOST = .*#DEFAULT_DB_DBHOST = os.getenv('DEFAULT_DB_DBHOST', '${DEFAULT_DB_DBHOST}')#g" settings.py + sed -i "s#DEFAULT_DB_DBPORT = .*#DEFAULT_DB_DBPORT = os.getenv('DEFAULT_DB_DBPORT', '${DEFAULT_DB_DBPORT}')#g" settings.py + sed -i "s#DEFAULT_DB_DBUSER = .*#DEFAULT_DB_DBUSER = os.getenv('DEFAULT_DB_DBUSER', '${DEFAULT_DB_DBUSER}')#g" settings.py + sed -i "s#DEFAULT_DB_DBPWD = .*#DEFAULT_DB_DBPWD = os.getenv('DEFAULT_DB_DBPWD', '${DEFAULT_DB_DBPWD}')#g" settings.py + sed -i "s#DEFAULT_DB_DBNAME = .*#DEFAULT_DB_DBNAME = os.getenv('DEFAULT_DB_DBNAME', '${DEFAULT_DB_DBNAME}')#g" settings.py + sed -i "s#READONLY_DB_DBHOST = .*#READONLY_DB_DBHOST = os.getenv('READONLY_DB_DBHOST', '${READONLY_DB_DBHOST}')#g" settings.py + sed -i "s#READONLY_DB_DBPORT = .*#READONLY_DB_DBPORT = os.getenv('READONLY_DB_DBPORT', '${READONLY_DB_DBPORT}')#g" settings.py + sed -i "s#READONLY_DB_DBUSER = .*#READONLY_DB_DBUSER = os.getenv('READONLY_DB_DBUSER', '${READONLY_DB_DBUSER}')#g" settings.py + sed -i "s#READONLY_DB_DBPWD = .*#READONLY_DB_DBPWD = os.getenv('READONLY_DB_DBPWD', '${READONLY_DB_DBPWD}')#g" settings.py + sed -i "s#READONLY_DB_DBNAME = .*#READONLY_DB_DBNAME = os.getenv('READONLY_DB_DBNAME', '${DEFAULT_DB_DBNAME}')#g" settings.py + sed -i "s#DEFAULT_REDIS_HOST = .*#DEFAULT_REDIS_HOST = os.getenv('DEFAULT_REDIS_HOST', '${DEFAULT_REDIS_HOST}')#g" settings.py + sed -i "s#DEFAULT_REDIS_PORT = .*#DEFAULT_REDIS_PORT = os.getenv('DEFAULT_REDIS_PORT', '${DEFAULT_REDIS_PORT}')#g" settings.py + sed -i "s#DEFAULT_REDIS_PASSWORD = .*#DEFAULT_REDIS_PASSWORD = os.getenv('DEFAULT_REDIS_PASSWORD', '${DEFAULT_REDIS_PASSWORD}')#g" settings.py -#python3 /var/www/kerrigan/db_sync.py \ No newline at end of file + +try_num=0 + +while [[ $try_num -le 100 ]]; +do + if $(curl -s ${DEFAULT_DB_DBHOST}:${DEFAULT_DB_DBPORT} > /dev/null);then + python3 db_sync.py + sleep 3 + mycli -h${DEFAULT_DB_DBHOST} -u${DEFAULT_DB_DBUSER} -p${MYSQL_PASSWORD} codo_admin < codo_admin_beta0.3.sql + check_admin_user_num=`mycli -h${DEFAULT_DB_DBHOST} -u${DEFAULT_DB_DBUSER} -p${MYSQL_PASSWORD} codo_admin -e "select username from mg_users where username='admin';" | wc -l` + if [ ${check_admin_user_num} -eq 0 ]; then + mysql -h${DEFAULT_DB_DBHOST} -u${DEFAULT_DB_DBUSER} -p${MYSQL_PASSWORD} codo_admin < ./codo_admin_beta0.3.sql; + else + echo "初始化用户已存在" ; + fi + + if [ $? -eq 0 ]; then + echo -e "\033[32m [INFO]: 导入codo-admin用户权限数据完成. \033[0m"; + else + echo -e "\033[31m [ERROR]: 导入codo-admin用户权限数据完成失败 \033[0m" && exit -6; + fi + + exit 0 + else + echo 'wait mysql start to do db_sync.py' + fi + let try_num+=1 + sleep 3 +done \ No newline at end of file diff --git a/docker/supervisor_ops.conf b/docker/supervisor_ops.conf index 520a4c6..f20419f 100644 --- a/docker/supervisor_ops.conf +++ b/docker/supervisor_ops.conf @@ -5,7 +5,7 @@ nodaemon=true programs=mg-prestart,mg,sub_log [program:mg-prestart] -command=sh prestart.sh +command=sh docker/prestart.sh directory=/var/www/codo-admin user=root autostart = true From ba6b22791e9b68f78dc7518a3072f31688e35080 Mon Sep 17 00:00:00 2001 From: Heaven Date: Sat, 13 Jun 2020 19:40:44 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=89=93=E5=8C=85?= =?UTF-8?q?=E9=95=9C=E5=83=8F,=E5=B0=86=E7=8E=AF=E5=A2=83=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=85=A8=E9=83=A8=E8=BD=AC=E4=B8=BA=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=86=85=E6=9D=A5=E6=93=8D=E4=BD=9C=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 1 + docker/nginx_default.conf | 64 +++++++++++++++++++ docker/nginx_ops.conf | 4 +- docker/prestart.sh | 18 +++--- .../codo_admin_beta0.3.sql | 0 5 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 docker/nginx_default.conf rename codo_admin_beta0.3.sql => sql/codo_admin_beta0.3.sql (100%) diff --git a/Dockerfile b/Dockerfile index ed46887..ed80703 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ ADD . /var/www/codo-admin/ RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r /var/www/codo-admin/requirements.txt +COPY docker/nginx_default.conf /etc/nginx/nginx.conf COPY docker/nginx_ops.conf /etc/nginx/conf.d/codo-admin.conf COPY docker/supervisor_ops.conf /etc/supervisord.conf diff --git a/docker/nginx_default.conf b/docker/nginx_default.conf new file mode 100644 index 0000000..e5709d3 --- /dev/null +++ b/docker/nginx_default.conf @@ -0,0 +1,64 @@ +user nginx; +worker_processes auto; +error_log /var/log/nginx/error.log; +pid /run/nginx.pid; + +# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. +include /usr/share/nginx/modules/*.conf; + +events { + worker_connections 1024; +} + +http { + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + # Load modular configuration files from the /etc/nginx/conf.d directory. + # See http://nginx.org/en/docs/ngx_core_module.html#include + # for more information. + include /etc/nginx/conf.d/*.conf; + +# Settings for a TLS enabled server. +# +# server { +# listen 443 ssl http2 default_server; +# listen [::]:443 ssl http2 default_server; +# server_name _; +# root /usr/share/nginx/html; +# +# ssl_certificate "/etc/pki/nginx/server.crt"; +# ssl_certificate_key "/etc/pki/nginx/private/server.key"; +# ssl_session_cache shared:SSL:1m; +# ssl_session_timeout 10m; +# ssl_ciphers HIGH:!aNULL:!MD5; +# ssl_prefer_server_ciphers on; +# +# # Load configuration files for the default server block. +# include /etc/nginx/default.d/*.conf; +# +# location / { +# } +# +# error_page 404 /404.html; +# location = /40x.html { +# } +# +# error_page 500 502 503 504 /50x.html; +# location = /50x.html { +# } +# } + +} \ No newline at end of file diff --git a/docker/nginx_ops.conf b/docker/nginx_ops.conf index 5229432..b765fd9 100644 --- a/docker/nginx_ops.conf +++ b/docker/nginx_ops.conf @@ -9,8 +9,8 @@ server { listen 80; server_name mg.opendevops.cn; - access_log /var/log/nginx/codo-admin_access.log; - error_log /var/log/nginx/codo-admin_error.log; + access_log /var/log/nginx/codo-admin-access.log; + error_log /var/log/nginx/codo-admin-error.log; location / { proxy_set_header Host $http_host; proxy_redirect off; diff --git a/docker/prestart.sh b/docker/prestart.sh index d1500ae..4ab72d4 100644 --- a/docker/prestart.sh +++ b/docker/prestart.sh @@ -5,6 +5,7 @@ cd /var/www/codo-admin/ echo -e "\033[32m [INFO]: 开始修改各项目的配置文件 \033[0m" sed -i "s#cookie_secret = .*#cookie_secret = '${cookie_secret}'#g" settings.py sed -i "s#token_secret = .*#token_secret = '${token_secret}'#g" settings.py + sed -i "s#secret_key = .*#secret_key = '${secret_key}'#g" settings.py DEFAULT_DB_DBNAME='codo_admin' sed -i "s#DEFAULT_DB_DBHOST = .*#DEFAULT_DB_DBHOST = os.getenv('DEFAULT_DB_DBHOST', '${DEFAULT_DB_DBHOST}')#g" settings.py sed -i "s#DEFAULT_DB_DBPORT = .*#DEFAULT_DB_DBPORT = os.getenv('DEFAULT_DB_DBPORT', '${DEFAULT_DB_DBPORT}')#g" settings.py @@ -28,18 +29,17 @@ do if $(curl -s ${DEFAULT_DB_DBHOST}:${DEFAULT_DB_DBPORT} > /dev/null);then python3 db_sync.py sleep 3 - mycli -h${DEFAULT_DB_DBHOST} -u${DEFAULT_DB_DBUSER} -p${MYSQL_PASSWORD} codo_admin < codo_admin_beta0.3.sql check_admin_user_num=`mycli -h${DEFAULT_DB_DBHOST} -u${DEFAULT_DB_DBUSER} -p${MYSQL_PASSWORD} codo_admin -e "select username from mg_users where username='admin';" | wc -l` - if [ ${check_admin_user_num} -eq 0 ]; then - mysql -h${DEFAULT_DB_DBHOST} -u${DEFAULT_DB_DBUSER} -p${MYSQL_PASSWORD} codo_admin < ./codo_admin_beta0.3.sql; - else - echo "初始化用户已存在" ; + if [ ${check_admin_user_num} -eq 1 ]; then + mycli -h${DEFAULT_DB_DBHOST} -u${DEFAULT_DB_DBUSER} -p${MYSQL_PASSWORD} codo_admin < sql/codo_admin_beta0.3.sql; + else + echo "初始化用户已存在" ; fi - - if [ $? -eq 0 ]; then - echo -e "\033[32m [INFO]: 导入codo-admin用户权限数据完成. \033[0m"; + + if [ $? -eq 0 ]; then + echo -e "\033[32m [INFO]: 导入codo-admin用户权限数据完成. \033[0m"; else - echo -e "\033[31m [ERROR]: 导入codo-admin用户权限数据完成失败 \033[0m" && exit -6; + echo -e "\033[31m [ERROR]: 导入codo-admin用户权限数据完成失败 \033[0m" && exit -6; fi exit 0 diff --git a/codo_admin_beta0.3.sql b/sql/codo_admin_beta0.3.sql similarity index 100% rename from codo_admin_beta0.3.sql rename to sql/codo_admin_beta0.3.sql From 714eaf086f4299a37eece428e40aa269b2556bd9 Mon Sep 17 00:00:00 2001 From: cyrus Date: Wed, 22 Jul 2020 15:21:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9sql=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/prestart.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/prestart.sh b/docker/prestart.sh index 4ab72d4..0794e44 100644 --- a/docker/prestart.sh +++ b/docker/prestart.sh @@ -20,7 +20,7 @@ cd /var/www/codo-admin/ sed -i "s#DEFAULT_REDIS_HOST = .*#DEFAULT_REDIS_HOST = os.getenv('DEFAULT_REDIS_HOST', '${DEFAULT_REDIS_HOST}')#g" settings.py sed -i "s#DEFAULT_REDIS_PORT = .*#DEFAULT_REDIS_PORT = os.getenv('DEFAULT_REDIS_PORT', '${DEFAULT_REDIS_PORT}')#g" settings.py sed -i "s#DEFAULT_REDIS_PASSWORD = .*#DEFAULT_REDIS_PASSWORD = os.getenv('DEFAULT_REDIS_PASSWORD', '${DEFAULT_REDIS_PASSWORD}')#g" settings.py - + sleep 30 try_num=0