wangdongxu

jira:NYJ-1460 desc:添加dockerfile

  1 +# Git
  2 +.git
  3 +.gitignore
  4 +
  5 +# IDE
  6 +.idea
  7 +.vscode
  8 +*.swp
  9 +*.swo
  10 +
  11 +# Python
  12 +__pycache__
  13 +*.py[cod]
  14 +*$py.class
  15 +*.so
  16 +.Python
  17 +.venv
  18 +venv/
  19 +
  20 +# Cache
  21 +.ruff_cache
  22 +.mypy_cache
  23 +.pytest_cache
  24 +.cache
  25 +
  26 +# Logs
  27 +logs/
  28 +*.log
  29 +
  30 +# Docker
  31 +dockerfiles/
  32 +Dockerfile
  33 +.dockerignore
1 -FROM aigc-embedding-service-base:latest  
2 -ENV PROJECT_ROOT=/app ENV=docker 1 +FROM python:3.12-slim
  2 +ARG DEBIAN_FRONTEND=noninteractive
  3 +ENV TZ=Asia/Shanghai PROJECT_ROOT=/app ENV=docker APP_LOG_TYPE=file,console
3 4
  5 +# 使用 Debian 的阿里云镜像
  6 +RUN echo "deb http://mirrors.aliyun.com/debian/ bookworm main contrib non-free" > /etc/apt/sources.list && \
  7 + echo "deb http://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free" >> /etc/apt/sources.list && \
  8 + echo "deb http://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free" >> /etc/apt/sources.list
  9 +
  10 +# 安装系统依赖
  11 +RUN apt update && apt install -y --no-install-recommends gcc curl vim && rm -rf /var/lib/apt/lists/*
  12 +# 安装uv工具
  13 +RUN pip install --no-cache-dir uv
4 WORKDIR /app 14 WORKDIR /app
5 -COPY app/ ./app/ 15 +COPY . .
  16 +RUN uv pip install --system --no-cache ".[es,postgres]"
6 17
7 EXPOSE 8000 18 EXPOSE 8000
8 -CMD ["python", "main.py"] 19 +
  20 +CMD ["python", "main.py"]
  1 +FROM baselib/aigc-embedding-service:base26402
  2 +ENV PROJECT_ROOT=/app ENV=docker APP_LOG_TYPE=file,console
  3 +
  4 +WORKDIR /app
  5 +
  6 +# 复制代码文件
  7 +COPY . .
  8 +
  9 +EXPOSE 8000
  10 +CMD ["python", "main.py"]
@@ -4,16 +4,10 @@ FROM python:3.12-slim @@ -4,16 +4,10 @@ FROM python:3.12-slim
4 ARG DEBIAN_FRONTEND=noninteractive 4 ARG DEBIAN_FRONTEND=noninteractive
5 ENV TZ=Asia/Shanghai 5 ENV TZ=Asia/Shanghai
6 6
7 -RUN cat > /etc/apt/sources.list <<EOF  
8 -deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse  
9 -deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse  
10 -deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse  
11 -deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse  
12 -deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse  
13 -deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse  
14 -deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse  
15 -deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse  
16 -EOF 7 +# 使用 Debian 的阿里云镜像
  8 +RUN echo "deb http://mirrors.aliyun.com/debian/ bookworm main contrib non-free" > /etc/apt/sources.list && \
  9 + echo "deb http://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free" >> /etc/apt/sources.list && \
  10 + echo "deb http://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free" >> /etc/apt/sources.list
17 11
18 # 安装系统依赖 12 # 安装系统依赖
19 RUN apt-get update && apt-get install -y --no-install-recommends gcc curl vim && rm -rf /var/lib/apt/lists/* 13 RUN apt-get update && apt-get install -y --no-install-recommends gcc curl vim && rm -rf /var/lib/apt/lists/*
@@ -21,8 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends gcc curl vim && @@ -21,8 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends gcc curl vim &&
21 # 安装uv工具 15 # 安装uv工具
22 RUN pip install --no-cache-dir uv 16 RUN pip install --no-cache-dir uv
23 WORKDIR /app 17 WORKDIR /app
24 -# 复制依赖文件  
25 -COPY ../pyproject.toml uv.lock ./  
26 18
27 -# 使用uv安装项目依赖(包含es和postgres可选依赖)  
28 -RUN uv pip install --system --no-cache -e ".[es,postgres]"  
  19 +# 复制依赖文件(从构建上下文根目录复制)
  20 +COPY pyproject.toml uv.lock ./
  21 +
  22 +RUN uv pip install --system --no-cache ".[es,postgres]"
1 import os 1 import os
2 from pathlib import Path 2 from pathlib import Path
3 3
4 -os.environ['PROJECT_ROOT'] = Path(__file__).parent.absolute().as_posix()  
5 -from aabd.base.patched_logging import set_global_logger, get_logger 4 +if not os.environ.get("PROJECT_ROOT"):
  5 + os.environ['PROJECT_ROOT'] = Path(__file__).parent.absolute().as_posix()
  6 +from aabd.base.patched_logging import init_logging, get_logger
6 7
7 -set_global_logger() 8 +init_logging()
8 logger = get_logger(__name__) 9 logger = get_logger(__name__)
9 10
10 from contextlib import asynccontextmanager 11 from contextlib import asynccontextmanager
@@ -11,6 +11,7 @@ dependencies = [ @@ -11,6 +11,7 @@ dependencies = [
11 "path==17.1.1", 11 "path==17.1.1",
12 "omegaconf==2.3.0", 12 "omegaconf==2.3.0",
13 "elasticsearch>=9.3.0", 13 "elasticsearch>=9.3.0",
  14 + "packaging==26.0",
14 ] 15 ]
15 16
16 [project.optional-dependencies] 17 [project.optional-dependencies]
@@ -50,3 +51,6 @@ testpaths = ["tests"] @@ -50,3 +51,6 @@ testpaths = ["tests"]
50 python_files = ["test_*.py"] 51 python_files = ["test_*.py"]
51 python_classes = ["Test*"] 52 python_classes = ["Test*"]
52 python_functions = ["test_*"] 53 python_functions = ["test_*"]
  54 +
  55 +[tool.setuptools]
  56 +packages = []