docker部署
parent
4d57607e3f
commit
c3f64f2d5c
|
@ -16,3 +16,4 @@ bin-release/
|
|||
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
|
||||
# should NOT be excluded as they contain compiler settings and other important
|
||||
# information for Eclipse / Flash Builder.
|
||||
./docker_env/mysql/data/
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
# start django command
|
||||
# local domain
|
||||
# saas-local.anthembj.com
|
||||
# ceshi-local.anthembj.com
|
||||
# docker-compose run --entrypoint '/backend/docker_start.sh' -p 8000:8000 docker_django
|
||||
|
||||
version: "3"
|
||||
services:
|
||||
|
||||
dvadmin-redis:
|
||||
image: redis:latest
|
||||
container_name: dvadmin-redis
|
||||
ports:
|
||||
- "6380:6379"
|
||||
expose:
|
||||
- "6379"
|
||||
volumes:
|
||||
- ./docker_env/redis/data:/data
|
||||
- ./docker_env/redis/redis.conf:/etc/redis/redis.conf
|
||||
command: redis-server /etc/redis/redis.conf
|
||||
networks:
|
||||
- dvadmin_net
|
||||
|
||||
|
||||
dvadmin-mysql:
|
||||
image: mysql:5.7
|
||||
container_name: dvadmin-mysql
|
||||
#使用该参数,container内的root拥有真正的root权限,否则,container内的root只是外部的一个普通用户权限
|
||||
#设置为true,不然数据卷可能挂载不了,启动不起
|
||||
privileged: true
|
||||
restart: always
|
||||
ports:
|
||||
- "3307:3306"
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: "q1w2e3r4T%Y^U&MYSQL"
|
||||
MYSQL_DATABASE: "dvadmin"
|
||||
TZ: Asia/Shanghai
|
||||
command:
|
||||
--wait_timeout=31536000
|
||||
--interactive_timeout=31536000
|
||||
--max_connections=1000
|
||||
--default-authentication-plugin=mysql_native_password
|
||||
volumes:
|
||||
#映射mysql的数据目录到宿主机,保存数据
|
||||
- "./docker_env/mysql/data:/var/lib/mysql"
|
||||
#根据宿主机下的配置文件创建容器
|
||||
- "./docker_env/mysql/conf.d:/etc/mysql/conf.d"
|
||||
- "./docker_env/mysql/logs:/logs"
|
||||
networks:
|
||||
- dvadmin_net
|
||||
|
||||
dvadmin-django:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./docker_env/django/Dockerfile
|
||||
# image: django:2.2
|
||||
container_name: dvadmin-django
|
||||
working_dir: /dvadmin-backend
|
||||
# command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --noinput && python manage.py runserver"
|
||||
# command: bash
|
||||
depends_on:
|
||||
- dvadmin-mysql
|
||||
- dvadmin-redis
|
||||
volumes:
|
||||
- ./dvadmin-backend:/dvadmin-backend
|
||||
- ./logs/log:/var/log
|
||||
ports:
|
||||
- "8000:8000"
|
||||
expose:
|
||||
- "8000"
|
||||
restart: always
|
||||
networks:
|
||||
- dvadmin_net
|
||||
|
||||
|
||||
# docker-celery:
|
||||
# build:
|
||||
# context: .
|
||||
# dockerfile: ./docker_env/celery/Dockerfile
|
||||
# # image: celery:1.0
|
||||
# container_name: docker-celery
|
||||
# working_dir: /dvadmin-backend
|
||||
# # command: bash
|
||||
# depends_on:
|
||||
# - dvadmin-mysql
|
||||
# - dvadmin-redis
|
||||
# - dvadmin-django
|
||||
# volumes:
|
||||
# - ./dvadmin-backend:/dvadmin-backend
|
||||
# - ./logs/log:/var/log
|
||||
# ports:
|
||||
# - "5672:5672"
|
||||
# expose:
|
||||
# - "5672"
|
||||
# restart: always
|
||||
# networks:
|
||||
# - dvadmin_net
|
||||
|
||||
|
||||
# dvadmin-nginx:
|
||||
# image: nginx:latest
|
||||
# container_name: docker-nginx
|
||||
# # build: ./docker_env/nginx
|
||||
# restart: always
|
||||
# ports:
|
||||
# - "80:80"
|
||||
# - "443:443"
|
||||
# expose:
|
||||
# - "80"
|
||||
# - "443"
|
||||
# volumes:
|
||||
# - ./docker_env/nginx/nginx.conf:/etc/nginx/nginx.conf
|
||||
# - ./docker_env/nginx/sites-enabled:/etc/nginx/sites-enabled
|
||||
# - ./docker_env/nginx/keys:/nginx/keys
|
||||
# - ./dvadmin-backend:/dvadmin-backend
|
||||
# - ./dvadmin-doc:/dvadmin-doc
|
||||
# - ./dvadmin-ui:/dvadmin-ui
|
||||
# - ./logs/nginx:/var/log/nginx
|
||||
# depends_on:
|
||||
# - dvadmin-django
|
||||
# networks:
|
||||
# - dvadmin_net
|
||||
|
||||
networks:
|
||||
dvadmin_net:
|
||||
driver: bridge
|
|
@ -1,8 +1,8 @@
|
|||
FROM python:3.7
|
||||
# ENV PYTHONUNBUFFERED 1
|
||||
# RUN sed -i s/deb.debian.org/mirrors.163.com/g /etc/apt/sources.list
|
||||
# RUN cat /etc/apt/sources.list
|
||||
# RUN apt-get clean
|
||||
RUN sed -i s/deb.debian.org/mirrors.163.com/g /etc/apt/sources.list
|
||||
RUN cat /etc/apt/sources.list
|
||||
RUN apt-get clean
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y build-essential
|
||||
RUN apt-get install -y python3.7-dev libpq-dev libopencv-dev python-opencv
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
### init 初始化项目
|
||||
### start 启动项目
|
||||
### stop 停止项目
|
||||
### restart 重启项目
|
||||
### -h 显示帮助信息.
|
||||
help() {
|
||||
awk -F'### ' '/^###/ { print $2 }' "$0"
|
||||
}
|
||||
|
||||
if [[ $# == 0 ]] || [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
|
||||
help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#初始化方法
|
||||
init(){
|
||||
echo "正在初始化中..."
|
||||
sudo find . -path "*/*/*/migrations/*.py" -not -name "__init__.py" -delete
|
||||
sudo rm -rf docker_env/mysql/data
|
||||
echo "初始化完成..."
|
||||
}
|
||||
|
||||
#启动方法
|
||||
start(){
|
||||
echo "正在启动中..."
|
||||
docker-compose up
|
||||
echo "启动完成..."
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
||||
init)
|
||||
echo "=== init "
|
||||
init
|
||||
start
|
||||
;;
|
||||
start)
|
||||
echo "=== start ";;
|
||||
|
||||
stop)
|
||||
echo "=== stop ";;
|
||||
|
||||
restart)
|
||||
echo "=== restart ";;
|
||||
|
||||
*)
|
||||
help
|
||||
exit 1
|
||||
|
||||
esac
|
Loading…
Reference in New Issue