forked from momosecurity/aswan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request momosecurity#60 from Flynnon/add_dockerfile
补充docker部署相关脚本及文档
- Loading branch information
Showing
12 changed files
with
205 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# coding=utf8 | ||
|
||
# 存储各项配置信息的redis | ||
REDIS_CONFIG = { | ||
"host": "redis_db", | ||
"port": 6379, | ||
"db": 1, | ||
"password": "", | ||
"max_connections": 40, | ||
"socket_timeout": 1, | ||
"decode_responses": True | ||
} | ||
|
||
# 作为命中日志队列的redis | ||
LOG_REDIS_CONFIG = { | ||
"host": "redis_db", | ||
"port": 6379, | ||
"db": 1, | ||
"password": "", | ||
"max_connections": 40, | ||
"socket_timeout": 1, | ||
"decode_responses": True | ||
} | ||
|
||
# 存储上报数据的redis | ||
REPORT_REDIS_CONFIG = { | ||
"host": "redis_db", | ||
"port": 6379, | ||
"db": 1, | ||
"password": "", | ||
"max_connections": 40, | ||
"socket_timeout": 1, | ||
"decode_responses": True | ||
} | ||
|
||
# 存储命中日志的mysql | ||
LOG_MYSQL_CONFIG = { | ||
'host': 'mysql_db', | ||
'port': 3306, | ||
'user': 'root', | ||
'passwd': 'root', | ||
'charset': 'utf8', | ||
'db': 'risk_control', | ||
} | ||
|
||
# 存储权限等信息的mongo | ||
SOC_MONGO_HOST = [ | ||
"mongo_db:27017", | ||
] | ||
|
||
MONGO_DB = "risk_control" | ||
|
||
RISK_SERVER_HOST = '0.0.0.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,5 +48,7 @@ | |
"127.0.0.1:27017", | ||
] | ||
|
||
MONGO_USER = "risk_control_user" | ||
MONGO_PWD = "risk_control_pwd" | ||
|
||
MONGO_DB = "risk_control" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM python:3.7.3 | ||
|
||
WORKDIR /app | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com | ||
COPY ./ . | ||
RUN rm -rf output | ||
|
||
CMD [ "python", "www/manage.py", "runserver", "0.0.0.0:8000"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM python:3.7.3 | ||
|
||
WORKDIR /app | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com | ||
COPY ./ . | ||
RUN rm -rf output | ||
|
||
CMD [ "python", "risk_server.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM python:3.7.3 | ||
|
||
WORKDIR /app | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com | ||
COPY ./ . | ||
RUN rm -rf output | ||
|
||
CMD [ "python", "www/manage.py", "persistence_hit_log"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
version: '3.3' | ||
|
||
services: | ||
app_python: | ||
build: | ||
context: ../ | ||
dockerfile: deploy/Dockerfile.backend | ||
depends_on: | ||
- redis_db | ||
- mongo_db | ||
- mysql_db | ||
ports: | ||
- "8000:8000" | ||
command: > | ||
bash -c "python www/manage.py collectstatic --noinput&& | ||
python www/manage.py migrate && | ||
python www/manage.py runserver 0.0.0.0:8000" | ||
environment: | ||
- RISK_ENV=docker | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
max_attempts: 8 | ||
|
||
app_service: | ||
build: | ||
context: ../ | ||
dockerfile: deploy/Dockerfile.service | ||
depends_on: | ||
- redis_db | ||
ports: | ||
- "50000:50000" | ||
environment: | ||
- RISK_ENV=docker | ||
|
||
app_task: | ||
build: | ||
context: ../ | ||
dockerfile: deploy/Dockerfile.task | ||
depends_on: | ||
- redis_db | ||
- mongo_db | ||
- mysql_db | ||
environment: | ||
- RISK_ENV=docker | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
max_attempts: 8 | ||
|
||
redis_db: | ||
image: redis:6.0.8 | ||
container_name: risk_redis | ||
ports: | ||
- "6379:6379" | ||
|
||
mongo_db: | ||
image: mongo:4.4.1 | ||
container_name: risk_mongo | ||
ports: | ||
- "27017:27017" | ||
|
||
mysql_db: | ||
image: mysql:5.6 | ||
container_name: risk_mysql | ||
ports: | ||
- "3306:3306" | ||
command: | ||
- --character-set-server=utf8mb4 | ||
- --collation-server=utf8mb4_unicode_ci | ||
environment: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: risk_control |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
gevent==1.4.0 | ||
greenlet==0.4.15 | ||
redis==2.10.5 | ||
hiredis==0.2.0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# coding=utf8 | ||
"""开发环境配置""" | ||
|
||
DATABASES = { | ||
'default': { | ||
"ENGINE": 'django.db.backends.mysql', | ||
"HOST": "mysql_db", | ||
"PORT": 3306, | ||
"USER": "root", | ||
"PASSWORD": "root", | ||
"DATABASE_CHARSET": "utf8", | ||
"NAME": "risk_control", | ||
}, | ||
} | ||
|
||
DEBUG = True |