docker、docker-compose
,参考:docker-compose安装yum update
mkdir /opt/vhosts/portainer
cd /opt/vhosts/portainer
touch docker-compose.yml
vim docker-compose.yml
version: '3'
services:
portainer:
image: portainer/portainer-ce
container_name: portainer
restart: always
ports:
- 9001:9000
command: -H unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
volumes:
portainer_data:
http://云服务器IP:9001
,创建管理员账号:admin / admin@123456mkdir /opt/vhosts/auto-test-plt-project
cd /opt/vhosts/auto-test-plt-project
git clone https://github.com/tengfei-jiao/auto_test_platform.git
git pull origin master
cd auto_test_platform
cp .env.sample .env
vim .env
复制以下内容到.env文件中,注意修改你的云服务IP
DEBUG=False
DATABASE_URL=mysql://auto_test_plt:atp2021$Atstudy@mysql-8:3306/auto_test_plt
TEST_PLT_API_TIMEOUT_CONNECT=3.1
TEST_PLT_API_TIMEOUT_RESP=30
LIST_PER_PAGE=10
LOG_DIR=/var/log/django
ERROR_LOG_FILE=error.log
INFO_LOG_FILE=info.log
LOG_TEST_PLT_LEVEL=WARNING
CELERY_BROKER_URL=amqp://rabbit:atstudy@你的云服务IP:5672/test_plt
CELERY_RESULT_EXPIRES=259200
CELERY_TASK_TIME_LIMIT=600
DINGTALK_WEB_HOOK_TOKEN=xxx
DINGTALK_WEB_HOOK_SIGN=xxx
# 构建镜像
cd /opt/vhosts/auto-test-plt-project/auto_test_platform
docker build -t auto_test_platform:v1.0.0 .
# 创建数据卷
cd /opt/vhosts/auto-test-plt-project
mkdir -p ./mysql-data
mkdir -p ./rabbitmq-data
mkdir -p ./logs/rabbitmq
mkdir -p ./logs/django
mkdir -p ./logs/worker
mkdir -p ./logs/beat
mkdir -p ./logs/flower
mkdir -p ./logs/nginx
mkdir -p ./nginx/
cd /opt/vhosts/auto-test-plt-project
touch nginx/nginx.conf
vim nginx/nginx.conf
复制以下内容到 nginx.conf中
#user nobody;
worker_processes 1;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name auto_test_platform;
location /static/ {
expires 30d;
autoindex on;
add_header Cache-Control private;
alias /static/;
}
location / {
proxy_pass http://auto_test_platform-web:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
}
创建 docker-compose.yml 文件,并执行:docker-compose up -d
cd /opt/vhosts/auto-test-plt-project
touch docker-compose.yml
vim docker-compose.yml
version: '3'
services:
db:
# ★注意:该镜像默认已经包含CONVERT_TZ所需的时区数据,不需要再从官网下载导入
image: mysql
container_name: mysql-8
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb_buffer_pool_size=512M
restart: always
ports:
- 3306:3306
volumes:
- ./mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: Woaizhongguo@21cen
MYSQL_DATABASE: auto_test_plt
MYSQL_USER: auto_test_plt
MYSQL_PASSWORD: atp2021$$Atstudy
# ★注意:小心在docker-compose yml中$字面量必须用$$代替,尽量避免在密码中使用$。
networks:
- default
phpmyadmin:
image: phpmyadmin
container_name: phpmyadmin
depends_on:
- db
restart: always
ports:
- 8080:80
environment:
- PMA_HOST=mysql-8
- PMA_PORT=3306
- UPLOAD_LIMIT=20M
networks:
- default
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq-common
# ★注意:先建立目录
volumes:
- ./rabbitmq-data/:/var/lib/rabbitmq/
restart: always
ports:
- 5672:5672
- 15672:15672
environment:
- RABBITMQ_DEFAULT_USER=rabbit
- RABBITMQ_DEFAULT_PASS=atstudy
networks:
- default
auto_test_plt:
# ★注意:先git clone源码然后构建镜像 docker build -t auto_test_platform:v1.0.0 .
image: auto_test_platform:v1.0.0
container_name: auto_test_platform-web
depends_on:
- db
working_dir: /app
# ★注意:先建立目录
volumes:
- ./auto_test_platform:/app
- ./logs/django:/var/log/django
expose:
- 8000
networks:
- default
# 注意worker和beat的日志级别,稳定投产之后就不要用info了
celery_worker:
image: auto_test_platform:v1.0.0
container_name: auto_test_platform-celery_worker
depends_on:
- auto_test_plt
- rabbitmq
working_dir: /app
# ★注意:先建立目录volumes
volumes:
- ./auto_test_platform:/app
- ./logs/worker:/var/log/worker
entrypoint: celery -A auto_test_platform worker -l info -f /var/log/worker/celery-worker.log
networks:
- default
celery_beat:
image: auto_test_platform:v1.0.0
container_name: auto_test_platform-celery_beat
depends_on:
- auto_test_plt
- rabbitmq
working_dir: /app
# ★注意:先建立目录
volumes:
- ./auto_test_platform:/app
- ./logs/beat:/var/log/beat
entrypoint: celery -A auto_test_platform beat -l info -f /var/log/beat/celery-beat.log
networks:
- default
celery_flower:
image: auto_test_platform:v1.0.0
container_name: auto_test_platform-celery_flower
depends_on:
- auto_test_plt
- rabbitmq
working_dir: /app
ports:
- 5555:5555
volumes:
- ./auto_test_platform:/app
- ./logs/flower:/var/log/flower
entrypoint: celery -A auto_test_platform flower --port=5555 --broker_api=http://rabbit:51testing@rabbitmq-common:15672/api/
networks:
- default
nginx:
image: nginx:latest
container_name: auto_test_platform-nginx
depends_on:
- auto_test_plt
# ★注意:先建立目录,复制nginx.conf
volumes:
- ./auto_test_platform/static:/static
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./logs/nginx:/var/log/nginx
ports:
- 80:80
networks:
- default
networks:
default:
driver: bridge
portainer平台:http://你的云服务IP:9001【admin / admin@123456】
phpmyadmin平台:http://你的云服务IP:8080/【auto_test_plt / atp2021$Atstudy】
flower平台:http://你的云服务IP:5555/
rabbitmq平台:http://你的云服务IP:15672/【rabbit / atstudy】
接口自动化测试平台:http://你的云服务IP/admin 【root / test@123】
其他问题的处理文章末加博主微信即可