From a10a565f64d4aa8420d8f1edb8bcfa8f72365185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=BB=BA=E5=B9=B3?= Date: Wed, 26 Feb 2025 18:07:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9F=E5=A4=A7=E7=9A=84=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=EF=BC=9A=E4=BC=98=E5=8C=96=E9=9D=99=E6=80=81=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=EF=BC=8C=E5=8A=A0=E5=85=A5Nginx=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E5=AE=89=E5=85=A8=E8=87=B3=E4=B8=8A=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- README.MD | 14 +++++++------- docker-compose.yaml | 13 +++++++++++++ pr_manager/settings.py | 10 ++++++++-- static/{ => md_image}/AI配置.png | Bin static/{ => md_image}/Git服务配置.png | Bin static/{ => md_image}/Webhook配置.png | Bin static/{ => md_image}/gitlab_access.png | Bin static/{ => md_image}/主页.png | Bin static/{ => md_image}/项目Secret.png | Bin static/{ => md_image}/项目配置.png | Bin static/nginx/pr.conf | 22 ++++++++++++++++++++++ 12 files changed, 52 insertions(+), 10 deletions(-) rename static/{ => md_image}/AI配置.png (100%) rename static/{ => md_image}/Git服务配置.png (100%) rename static/{ => md_image}/Webhook配置.png (100%) rename static/{ => md_image}/gitlab_access.png (100%) rename static/{ => md_image}/主页.png (100%) rename static/{ => md_image}/项目Secret.png (100%) rename static/{ => md_image}/项目配置.png (100%) create mode 100644 static/nginx/pr.conf diff --git a/.gitignore b/.gitignore index 17ed811..35ca4c7 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ build/ docs/.cache/ .qodo db.sqlite3 -#pr_agent/ \ No newline at end of file +#pr_agent/ +static/admin/ \ No newline at end of file diff --git a/README.MD b/README.MD index 0415576..254c99e 100644 --- a/README.MD +++ b/README.MD @@ -86,18 +86,18 @@ python manage.py runserver ## PR管理系统配置说明 -![主页菜单](static/主页.png) +![主页菜单](static/md_image/主页.png) 所有配置均通过 Django admin 后台管理,主要包括: - **AI 服务器**:配置 AI 服务接入信息。 -![AI 服务器](static/AI配置.png) +![AI 服务器](static/md_image/AI配置.png) - **Git 服务器**:配置与各 Git 服务的连接及 webhook 信息。 -![Git 服务器](static/Git服务配置.png) +![Git 服务器](static/md_image/Git服务配置.png) -![项目配置](static/项目配置.png) +![项目配置](static/md_image/项目配置.png) - **指令设置**:配置在 webhook 触发时需要执行的各项指令(例如代码审核、描述与改进)。 @@ -107,15 +107,15 @@ python manage.py runserver - **用户AccessToken**: 配置Gitlab用户的AccessToken,用于获取用户信息。 -![用户AccessToken](static/gitlab_access.png) +![用户AccessToken](static/md_image/gitlab_access.png) - **项目Secret**: 配置Gitlab项目的Secret,用于验证请求的合法性。 -![项目Secret](static/项目Secret.png) +![项目Secret](static/md_image/项目Secret.png) - **Webhook配置**: 配置Gitlab项目的Webhook,用于处理Gitlab的推送事件。 -![Webhook配置](static/Webhook配置.png) +![Webhook配置](static/md_image/Webhook配置.png) ## 默认账号及 Git 服务器支持 diff --git a/docker-compose.yaml b/docker-compose.yaml index 407cf36..4089641 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,4 +1,17 @@ services: + nginx: + image: nginx:latest + container_name: nginx + ports: + - "10008:80" + volumes: + - ./static/nginx:/etc/nginx/conf.d + - ./static/:/app/static + logging: + driver: "json-file" + options: + max-size: "50M" + max-file: "1" # admin服务 backend: image: pr_manager:latest diff --git a/pr_manager/settings.py b/pr_manager/settings.py index f6a42d3..d2a19e0 100644 --- a/pr_manager/settings.py +++ b/pr_manager/settings.py @@ -27,7 +27,7 @@ sys.path.insert(1, os.path.join(BASE_DIR, "apps/utils")) SECRET_KEY = "django-insecure-$r6lfcq8rev&&=chw259o$0o7t-!!%clc2ahs3xg$^z+gkms76" # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False ALLOWED_HOSTS = ["*"] @@ -128,11 +128,17 @@ USE_L10N = True USE_TZ = False +# 全局时间格式化 +DATETIME_FORMAT = "Y-m-d H:i:sO" +date_format = 'Y-m-d' # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "static/" +STATIC_URL = "/static/" + +# 生产环境目录 +STATIC_ROOT = BASE_DIR / "static" # Default primary key field type # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field diff --git a/static/AI配置.png b/static/md_image/AI配置.png similarity index 100% rename from static/AI配置.png rename to static/md_image/AI配置.png diff --git a/static/Git服务配置.png b/static/md_image/Git服务配置.png similarity index 100% rename from static/Git服务配置.png rename to static/md_image/Git服务配置.png diff --git a/static/Webhook配置.png b/static/md_image/Webhook配置.png similarity index 100% rename from static/Webhook配置.png rename to static/md_image/Webhook配置.png diff --git a/static/gitlab_access.png b/static/md_image/gitlab_access.png similarity index 100% rename from static/gitlab_access.png rename to static/md_image/gitlab_access.png diff --git a/static/主页.png b/static/md_image/主页.png similarity index 100% rename from static/主页.png rename to static/md_image/主页.png diff --git a/static/项目Secret.png b/static/md_image/项目Secret.png similarity index 100% rename from static/项目Secret.png rename to static/md_image/项目Secret.png diff --git a/static/项目配置.png b/static/md_image/项目配置.png similarity index 100% rename from static/项目配置.png rename to static/md_image/项目配置.png diff --git a/static/nginx/pr.conf b/static/nginx/pr.conf new file mode 100644 index 0000000..935bd19 --- /dev/null +++ b/static/nginx/pr.conf @@ -0,0 +1,22 @@ +server { + listen 80; + server_name localhost; + client_max_body_size 512M; + keepalive_timeout 1800s; + sendfile on; + chunked_transfer_encoding on; + + + location /static { + alias /app/static/; + } + + location / { + proxy_set_header Access-Control-Allow-Origin *; + proxy_set_header Access-Control-Allow-Methods *; + proxy_set_header Access-Control-Allow-Headers *; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_pass http://backend:18000; + } +} \ No newline at end of file