From b250573e725c16e22a1f0b719b6a255a490d8e9f Mon Sep 17 00:00:00 2001 From: Sun-ZhenXing <1006925066@qq.com> Date: Sun, 21 Sep 2025 20:54:17 +0800 Subject: [PATCH] feat: add ollama & PostgresSQL & Qdrant & RabbitMQ --- LICENSE | 21 ++++++++++++++++++ src/ollama/README.md | 19 ++++++++++++++++ src/ollama/docker-compose.yml | 35 +++++++++++++++++++++++++++++ src/postgres/.env.example | 1 + src/postgres/docker-compose.yaml | 38 ++++++++++++++++++++++++++++++++ src/qdrant/.env.example | 14 ++++++++++++ src/qdrant/README.md | 5 +++++ src/qdrant/docker-compose.yaml | 35 +++++++++++++++++++++++++++++ src/rabbitmq/README.md | 1 + src/rabbitmq/docker-compose.yaml | 35 +++++++++++++++++++++++++++++ src/redis/docker-compose.yaml | 2 +- 11 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 LICENSE create mode 100644 src/ollama/README.md create mode 100644 src/ollama/docker-compose.yml create mode 100644 src/postgres/.env.example create mode 100644 src/postgres/docker-compose.yaml create mode 100644 src/qdrant/.env.example create mode 100644 src/qdrant/README.md create mode 100644 src/qdrant/docker-compose.yaml create mode 100644 src/rabbitmq/README.md create mode 100644 src/rabbitmq/docker-compose.yaml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7bef9ce --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Alex Sun + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/ollama/README.md b/src/ollama/README.md new file mode 100644 index 0000000..29695d3 --- /dev/null +++ b/src/ollama/README.md @@ -0,0 +1,19 @@ +# Ollama + +拉取 DeepSeek R1 7B 模型: + +```bash +docker exec -it ollama ollama pull deepseek-r1:7b +``` + +列出本地所有模型: + +```bash +docker exec -it ollama ollama list +``` + +API 请求获取本地所有模型: + +```bash +curl http://localhost:11434/api/tags 2> /dev/null | jq +``` diff --git a/src/ollama/docker-compose.yml b/src/ollama/docker-compose.yml new file mode 100644 index 0000000..c42e4bc --- /dev/null +++ b/src/ollama/docker-compose.yml @@ -0,0 +1,35 @@ +x-default: &default + restart: unless-stopped + volumes: + - &localtime /etc/localtime:/etc/localtime:ro + - &timezone /etc/timezone:/etc/timezone:ro + logging: + driver: json-file + options: + max-size: 100m + +services: + ollama: + <<: *default + image: ollama/ollama:${OLLAMA_VERSION:-0.12.0} + ports: + - "${OLLAMA_PORT:-11434}:11434" + volumes: + - *localtime + - *timezone + - ollama_models:/root/.ollama + deploy: + resources: + limits: + cpus: '8.0' + memory: 4G + reservations: + cpus: '2.0' + memory: 2G + devices: + - driver: nvidia + device_ids: [ '0' ] + capabilities: [ gpu ] + +volumes: + ollama_models: diff --git a/src/postgres/.env.example b/src/postgres/.env.example new file mode 100644 index 0000000..c14aa52 --- /dev/null +++ b/src/postgres/.env.example @@ -0,0 +1 @@ +POSTGRES_PASSWORD= diff --git a/src/postgres/docker-compose.yaml b/src/postgres/docker-compose.yaml new file mode 100644 index 0000000..a06b994 --- /dev/null +++ b/src/postgres/docker-compose.yaml @@ -0,0 +1,38 @@ +x-default: &default + restart: unless-stopped + volumes: + - &localtime /etc/localtime:/etc/localtime:ro + - &timezone /etc/timezone:/etc/timezone:ro + logging: + driver: json-file + options: + max-size: 100m + +services: + postgres: + <<: *default + image: postgres:${POSTGRES_VERSION:-17.6} + environment: + POSTGRES_USER: ${POSTGRES_USER:-postgres} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres} + POSTGRES_DB: ${POSTGRES_DB:-postgres} + volumes: + - *localtime + - *timezone + - postgres_data:/var/lib/postgresql/data + + # Initialize the database with a custom SQL script + # - ./init.sql:/docker-entrypoint-initdb.d/init.sql + ports: + - "${POSTGRES_PORT:-5432}:5432" + deploy: + resources: + limits: + cpus: '1.0' + memory: 1G + reservations: + cpus: '0.5' + memory: 512M + +volumes: + postgres_data: diff --git a/src/qdrant/.env.example b/src/qdrant/.env.example new file mode 100644 index 0000000..bec0da0 --- /dev/null +++ b/src/qdrant/.env.example @@ -0,0 +1,14 @@ +# Qdrant Version +QDRANT_VERSION="v1.15.4" + +# Qdrant API Key +QDRANT_API_KEY= + +# Use RBAC +QDRANT_JWT_RBAC=true + +# HTTP Port +QDRANT_HTTP_PORT= + +# gRPC Port +QDRANT_GRPC_PORT= diff --git a/src/qdrant/README.md b/src/qdrant/README.md new file mode 100644 index 0000000..6e1c3b6 --- /dev/null +++ b/src/qdrant/README.md @@ -0,0 +1,5 @@ +# Qdrant + +## 鉴权 + +Qdrant 支持 [API 密钥](https://qdrant.tech/documentation/guides/security/#read-only-api-key)和 [JWT 令牌](https://qdrant.tech/documentation/guides/security/#granular-access-control-with-jwt)两种鉴权方式。 diff --git a/src/qdrant/docker-compose.yaml b/src/qdrant/docker-compose.yaml new file mode 100644 index 0000000..332e68f --- /dev/null +++ b/src/qdrant/docker-compose.yaml @@ -0,0 +1,35 @@ +x-default: &default + restart: unless-stopped + volumes: + - &localtime /etc/localtime:/etc/localtime:ro + - &timezone /etc/timezone:/etc/timezone:ro + logging: + driver: json-file + options: + max-size: 100m + +services: + qdrant: + <<: *default + image: qdrant/qdrant:${QDRANT_VERSION:-v1.15.4} + ports: + - "${QDRANT_HTTP_PORT:-6333}:6333" + - "${QDRANT_GRPC_PORT:-6334}:6334" + volumes: + - *localtime + - *timezone + - qdrant_data:/qdrant/storage:z + environment: + - QDRANT__SERVICE__API_KEY=${QDRANT_API_KEY} + - QDRANT__SERVICE__JWT_RBAC=${QDRANT_JWT_RBAC:-false} + deploy: + resources: + limits: + cpus: '1.0' + memory: 1G + reservations: + cpus: '0.5' + memory: 256M + +volumes: + qdrant_data: diff --git a/src/rabbitmq/README.md b/src/rabbitmq/README.md new file mode 100644 index 0000000..63b005e --- /dev/null +++ b/src/rabbitmq/README.md @@ -0,0 +1 @@ +# RabbitMQ diff --git a/src/rabbitmq/docker-compose.yaml b/src/rabbitmq/docker-compose.yaml new file mode 100644 index 0000000..53993d8 --- /dev/null +++ b/src/rabbitmq/docker-compose.yaml @@ -0,0 +1,35 @@ +x-default: &default + restart: unless-stopped + volumes: + - &localtime /etc/localtime:/etc/localtime:ro + - &timezone /etc/timezone:/etc/timezone:ro + logging: + driver: json-file + options: + max-size: 100m + +services: + rabbitmq: + <<: *default + image: rabbitmq:${RABBITMQ_VERSION:-4.1.4-management-alpine} + volumes: + - rabbitmq_data:/var/lib/rabbitmq + - *localtime + - *timezone + ports: + - ${RABBITMQ_PORT:-5672}:5672 + - ${RABBITMQ_MANAGEMENT_PORT:-15672}:15672 + environment: + RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER:-admin} + RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS:-password} + deploy: + resources: + limits: + cpus: '1.0' + memory: 1G + reservations: + cpus: '0.5' + memory: 512M + +volumes: + rabbitmq_data: diff --git a/src/redis/docker-compose.yaml b/src/redis/docker-compose.yaml index be0d31a..7f33428 100644 --- a/src/redis/docker-compose.yaml +++ b/src/redis/docker-compose.yaml @@ -20,7 +20,7 @@ services: - *timezone - redis_data:/data - # !! Uncomment to use a custom redis.conf file + # Use a custom redis.conf file # - ./redis.conf:/etc/redis/redis.conf environment: - SKIP_FIX_PERMS=${SKIP_FIX_PERMS:-}