Skip to content

Commit 40ff12b

Browse files
author
yangmv
committed
edit
1 parent a0d5a79 commit 40ff12b

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ENV TZ=Asia/Shanghai
77
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
88

99
# 1. 安装基本依赖
10-
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 net-tools groupinstall development libxslt-devel libxml2-devel libcurl-devel git -y
10+
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 net-tools mariadb-devel groupinstall development libxslt-devel libxml2-devel libcurl-devel git -y
1111

1212
# 2. 准备python
1313
RUN wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz
@@ -19,11 +19,11 @@ ADD . /var/www/CMDB/
1919

2020
# 4. 安装pip依赖
2121
RUN pip3 install --user --upgrade pip
22-
RUN pip3 install -r /var/www/SuperCMDB/requirements.txt
22+
RUN pip3 install -r /var/www/CMDB/requirements.txt
2323

2424
# 5. 数据初始化
25-
RUN python3 /var/www/SuperCMDB/manage.py makemigrations
26-
RUN python3 /var/www/SuperCMDB/manage.py migrate
25+
RUN python3 /var/www/CMDB/manage.py makemigrations
26+
RUN python3 /var/www/CMDB/manage.py migrate
2727

2828
# 6. 日志
2929
VOLUME /var/log/

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pip3 install -r requirements.txt
2626

2727
#### 三 同步数据库
2828
```
29+
mysql -h 127.0.0.1 -u root -p123456 -e "create database cmdb default character set utf8mb4 collate utf8mb4_unicode_ci;"
2930
python3 manage.py makemigrations
3031
python3 manage.py migrate
3132
```
@@ -37,7 +38,7 @@ cat >> /etc/supervisord.conf <<EOF
3738
command=python3 startup.py --port=80%(process_num)02d
3839
process_name=%(program_name)s_%(process_num)02d
3940
numprocs=3
40-
directory=/var/www/SuperCMDB
41+
directory=/var/www/CMDB
4142
user=root
4243
autostart=true
4344
autorestart=true

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
cmdb:
22
restart: unless-stopped
3-
image: cmdb_image
3+
image: cmdb:latest
44
volumes:
55
- /var/log/supervisor/:/var/log/supervisor/
6+
- /var/www/CMDB/:/var/www/CMDB/
67
- /sys/fs/cgroup:/sys/fs/cgroup
78
ports:
89
- "8002:80"
910
hostname: cmdb-exec01
1011

1112
# docker-compose up -d
1213
# docker-compose down
13-
# 接口测试: http://k8s.yangmv.com:8001/v1/k8s/publish/
14+
# 接口测试: http://cmdb.opendevops.cn:8002/v1/cmdb/server/

docs/nginx_cmdb.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
upstream cmdb{
2-
server 127.0.0.1:8000;
3-
server 127.0.0.1:8001;
4-
server 127.0.0.1:8002;
2+
server 127.0.0.1:9000;
3+
server 127.0.0.1:9001;
4+
server 127.0.0.1:9002;
55
}
66

77
server
88
{
99
listen 80;
10-
server_name cmdb.yangmv.com;
10+
server_name cmdb.opendevops.cn;
1111
access_log /var/log/nginx/cmdb_access.log;
1212
error_log /var/log/nginx/cmdb_error.log;
1313
index index.html index.htm;
@@ -25,7 +25,7 @@ server
2525
# alias /var/www/CMDB/static;
2626
#}
2727

28-
location /api/cmdb/ {
28+
location /v1/cmdb/ {
2929
proxy_set_header Host $http_host;
3030
proxy_redirect off;
3131
proxy_set_header X-Real-IP $remote_addr;

docs/supervisor_cmdb.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ nodaemon=true
55
command=python3 startup.py --port=90%(process_num)02d
66
process_name=%(program_name)s_%(process_num)02d
77
numprocs=3
8-
directory=/var/www/SuperCMDB
8+
directory=/var/www/CMDB
99
user=root
1010
autostart=true
1111
autorestart=true

ops/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
urlpatterns = [
66
path('admin/', admin.site.urls),
7+
path('v1/cmdb/docs/', get_swagger_view(title='API文档')),
78
path('v1/cmdb/', include('assets.urls',namespace='api-assets')),
89
path('api-auth/', include('rest_framework.urls',namespace='rest_framework')),
9-
path('docs/', get_swagger_view(title='API文档')),
1010
]

0 commit comments

Comments
 (0)