mirror of
https://github.com/xhongc/music-tag-web.git
synced 2026-04-26 11:41:07 +08:00
feature: docker部署方式
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# django
|
||||
1 内置celery,beat
|
||||
2 drf, 返回值规范
|
||||
|
||||
#vue
|
||||
1 api层
|
||||
2 views层
|
||||
3 vuex层
|
||||
4 router层
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import os
|
||||
|
||||
# lib文件夹中手动导入的第三方库
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(1, os.path.join(os.getcwd(), 'lib'))
|
||||
|
||||
BROKER_URL = "redis://localhost:6379/3"
|
||||
# docker 中redis
|
||||
BROKER_URL = "redis://redis:6379/3"
|
||||
|
||||
SECRET_KEY = 'django-insecure-u5_r=pekio0@zt!y(kgbufuosb9mddu8*qeejkzj@=7uyvb392'
|
||||
|
||||
@@ -74,8 +76,8 @@ DATABASES = {
|
||||
"ENGINE": "django.db.backends.mysql",
|
||||
"NAME": "bomboo", # noqa
|
||||
"USER": "root",
|
||||
"PASSWORD": "",
|
||||
"HOST": "localhost",
|
||||
"PASSWORD": "xhongc",
|
||||
"HOST": "mysql",
|
||||
"PORT": "3306",
|
||||
# 单元测试 DB 配置,建议不改动
|
||||
"TEST": {"NAME": "test_db", "CHARSET": "utf8", "COLLATION": "utf8_general_ci"},
|
||||
@@ -138,4 +140,3 @@ try:
|
||||
from local_settings import * # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
50
docker-compose.yml
Normal file
50
docker-compose.yml
Normal file
@@ -0,0 +1,50 @@
|
||||
version: '3.7'
|
||||
services:
|
||||
redis:
|
||||
image: redis
|
||||
restart: always
|
||||
django-vue-cli:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker_file/django_vue_cli/Dockerfile
|
||||
image: "django-vue-cli"
|
||||
container_name: "django-vue-cli-container"
|
||||
command: bash -c "python manage.py migrate&&gunicorn -w 1 -k gevent -b 0.0.0.0:8000 django_vue_cli.wsgi:application"
|
||||
depends_on:
|
||||
- redis
|
||||
- mysql
|
||||
links:
|
||||
- redis
|
||||
- mysql
|
||||
expose:
|
||||
- "8000"
|
||||
volumes:
|
||||
- .:/django-vue-cli
|
||||
nginx:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker_file/nginx/Dockerfile
|
||||
image: "nginx-dv"
|
||||
container_name: "nginx-dv-container"
|
||||
depends_on:
|
||||
- django-vue-cli
|
||||
links:
|
||||
- django-vue-cli
|
||||
volumes:
|
||||
- ./static:/home/ubuntu/static
|
||||
ports:
|
||||
- "80:80"
|
||||
mysql:
|
||||
image: mysql
|
||||
container_name: mysql-with-django-vue
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_DATABASE=bomboo
|
||||
- MYSQL_ROOT_PASSWORD=xhongc
|
||||
expose:
|
||||
- "3306"
|
||||
ports:
|
||||
- "3306:3306"
|
||||
command:
|
||||
- "--character-set-server=utf8mb4"
|
||||
- "--collation-server=utf8mb4_unicode_ci"
|
||||
11
docker_file/django_vue_cli/Dockerfile
Normal file
11
docker_file/django_vue_cli/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM python:3.9
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /etc/apt/sources.list && rm -Rf /var/lib/apt/lists/* && apt-get update
|
||||
RUN apt-get install -y gettext python3-dev libpq-dev
|
||||
RUN mkdir /django-vue-cli
|
||||
WORKDIR /django-vue-cli
|
||||
ADD ./requirements.txt /django-vue-cli/
|
||||
|
||||
RUN pip install -r /django-vue-cli/requirements.txt -i https://mirrors.aliyun.com/pypi/simple/
|
||||
|
||||
EXPOSE 80 8000
|
||||
7
docker_file/nginx/Dockerfile
Normal file
7
docker_file/nginx/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM nginx
|
||||
|
||||
EXPOSE 80
|
||||
RUN mkdir -p /home/ubuntu/django_vue_log
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
ADD ./docker_file/nginx/nginx-dv.conf /etc/nginx/conf.d/
|
||||
ADD ./templates/index.html /home/ubuntu/
|
||||
14
docker_file/nginx/nginx-dv.conf
Normal file
14
docker_file/nginx/nginx-dv.conf
Normal file
@@ -0,0 +1,14 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name 127.0.0.1;
|
||||
location /static {
|
||||
alias /home/ubuntu/static;
|
||||
}
|
||||
location / {
|
||||
proxy_pass http://django-vue-cli:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
root /home/ubuntu;
|
||||
index index.html;
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,5 @@ mysqlclient==1.4.4
|
||||
python-dateutil==2.8.2
|
||||
redis==3.5.3
|
||||
requests==2.27.1
|
||||
gunicorn==20.1.0
|
||||
gevent==21.12.0
|
||||
Reference in New Issue
Block a user