Skip to content
Django 项目脚手架/Django project deploy with docker/Django 项目 Docker 部署/nginx/postgresql/redis/rabbitmq/celery/drf
Python Shell Dockerfile Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
apps
compose
conf
deploy/kubernetes
k8sdjango
logs
.editorconfig
.gitignore
.gitlab-ci.yml
Dockerfile
Makefile
README.md
agents.png
docker-compose-dev.yml
docker-compose-stack.yml
docker-compose.yml
k8s_pg-pv.yml
k8s_pg.yml
locustfile.py
manage.py
rabbitmq_stomp.py
requirements.txt
requirements_gitlab.txt
wait-for

README.md

k8sdjango

Language

Django 项目 Docker 部署示例,postgresql 配置映射到容器中,修改成可远程连接,nginx/gunicorn 日志映射到宿主机器,postgresql/redis/rabbitmq 容器数据持久化,映射 volume 到宿主机,ADMIN 的静态文件映射到宿主机器。

docker 单机

cd k8sdjango
docker-compose build
docker-compose up

docker swarm 集群

三台机器,一台 master,两台 worker,都需要同步代码以及 build 镜像

在 master 上:

cd k8sdjango
docker-compose build

# 启动所有服务
docker stack deplpoy docker-compose-stack.yml k8sdjango

# 查看服务列表,replica 是否都启动完成
docker services list

# 关闭所有服务
docker stack down k8sdjango

组件

  • python 3.7.4
  • postgresql 11.5
  • redis 5.0.5
  • rabbitmq 3.7.17 with management web UI
  • nginx 1.16
  • djangorestframework
  • celery

端口占用

  • nginx 8080
  • postgresql 5432 可远程连接
  • redis 6379 不可远程连接
  • rabbitmq 5672/15672(management web UI可使用)

rabbitmq + stomp

rabbitmq_stomp.py 向队列发送消息

ROADMAP

  • celery broker 换成 rabbitmq
  • nginx 日志映射出来
  • docker swarm 集群部署
  • k8s 集群部署
You can’t perform that action at this time.