diff --git a/容器配置文件/python_s2_lessie_sourcing_agents/Dockerfile b/容器配置文件/python_s2_lessie_sourcing_agents/Dockerfile new file mode 100644 index 0000000..949e3b6 --- /dev/null +++ b/容器配置文件/python_s2_lessie_sourcing_agents/Dockerfile @@ -0,0 +1,47 @@ +FROM python:3.12-slim AS builder + +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 \ + UV_LINK_MODE=copy \ + UV_VERSION=0.4.17 \ + UV_PROJECT_ENVIRONMENT=/opt/venv + +WORKDIR /app + +# Install build prerequisites, fetch uv, then remove leftover apt metadata. +RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates build-essential && \ + rm -rf /var/lib/apt/lists/* + +RUN curl -LsSf https://astral.sh/uv/install.sh | sh -s -- --version "${UV_VERSION}" + +# Pre-copy manifests for better layer caching. +COPY pyproject.toml uv.lock requirements.txt ./ + +RUN /root/.local/bin/uv sync --frozen --no-dev --python /usr/local/bin/python && \ + /root/.local/bin/uv cache prune --ci + +FROM python:3.12-slim AS runtime + +ARG APP_PORT=8000 + +ENV APP_ENV=local \ + APP_PORT=${APP_PORT} + +WORKDIR /app + +# Runtime dependencies required by packages like faiss-cpu. +RUN apt-get update && apt-get install -y --no-install-recommends libgomp1 && \ + rm -rf /var/lib/apt/lists/* + +# Bring in the pre-built virtual environment from the builder stage. +COPY --from=builder /opt/venv /opt/venv + +# Ship only the application sources in the runtime image. +COPY . . + +ENV PATH="/opt/venv/bin:${PATH}" \ + VIRTUAL_ENV="/opt/venv" + +EXPOSE ${APP_PORT} + +CMD ["sh", "-c", "python server.py --host ${HOST:-0.0.0.0} --port ${APP_PORT:-8000}"] diff --git a/容器配置文件/python_s2_lessie_sourcing_agents/docker-compose.yml b/容器配置文件/python_s2_lessie_sourcing_agents/docker-compose.yml new file mode 100644 index 0000000..e69de29