更改
This commit is contained in:
71
Dockerfile/python/lessie-sourcing-agents/Dockerfile
Normal file
71
Dockerfile/python/lessie-sourcing-agents/Dockerfile
Normal file
@@ -0,0 +1,71 @@
|
||||
FROM uswccr.ccs.tencentyun.com/lessie/python:3.12-slim AS builder
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1
|
||||
|
||||
WORKDIR /data/webapps/lessie_sourcing_agents
|
||||
|
||||
# Install build prerequisites required for native wheels, then remove leftover apt metadata.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
cmake \
|
||||
curl \
|
||||
git \
|
||||
libomp-dev \
|
||||
libopenblas-dev \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN python -m pip install --no-cache-dir "uv"
|
||||
|
||||
COPY pyproject.toml uv.lock requirements.in requirements.txt ./
|
||||
|
||||
# RUN python -m uv venv --python /usr/local/bin/python /opt/venv && \
|
||||
# python -m uv pip install --python /opt/venv/bin/python --no-cache -r requirements.txt
|
||||
|
||||
ENV UV_PROJECT_ENVIRONMENT=/opt/venv
|
||||
|
||||
RUN python -m uv venv /opt/venv && \
|
||||
python -m uv sync --frozen --no-dev --python /usr/local/bin/python
|
||||
|
||||
FROM uswccr.ccs.tencentyun.com/lessie/python:3.12-slim AS runtime
|
||||
|
||||
ARG APP_PORT=8000
|
||||
|
||||
ENV APP_ENV=local \
|
||||
APP_PORT=${APP_PORT}
|
||||
|
||||
WORKDIR /data/webapps/lessie_sourcing_agents
|
||||
|
||||
# Runtime dependencies required by packages like faiss-cpu.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libgomp1 \
|
||||
libomp5 \
|
||||
libopenblas0 \
|
||||
&& \
|
||||
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}
|
||||
|
||||
RUN mkdir -p /data/webapps/lessie_sourcing_agents/logs
|
||||
|
||||
COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
ENV LOG_DIR=/data/webapps/lessie_sourcing_agents/logs
|
||||
|
||||
VOLUME ["/data/webapps/lessie_sourcing_agents/logs"]
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_HOST="${HOST:-0.0.0.0}"
|
||||
APP_PORT="${APP_PORT:-8000}"
|
||||
APP_ENV_VALUE="${APP_ENV:-s2}"
|
||||
LOG_DIRECTORY="${LOG_DIR:-/data/webapps/lessie_sourcing_agents/logs}"
|
||||
TIMESTAMP="$(date +"%Y%m%d_%H%M%S")"
|
||||
LOGFILE="${LOG_DIRECTORY}/lessie_sourcing_agents_${TIMESTAMP}.log"
|
||||
LATEST_LINK="${LOG_DIRECTORY}/lessie_sourcing_agents_latest.log"
|
||||
GUNICORN_WORKERS="${GUNICORN_WORKERS:-8}"
|
||||
GUNICORN_TIMEOUT="${GUNICORN_TIMEOUT:-300}"
|
||||
GUNICORN_WORKER_CLASS="${GUNICORN_WORKER_CLASS:-uvicorn.workers.UvicornWorker}"
|
||||
GUNICORN_MODULE="${GUNICORN_MODULE:-dialogue.app:app}"
|
||||
|
||||
mkdir -p "${LOG_DIRECTORY}"
|
||||
touch "${LOGFILE}"
|
||||
ln -sf "${LOGFILE}" "${LATEST_LINK}"
|
||||
|
||||
echo "Starting gunicorn (${GUNICORN_MODULE}) with APP_ENV=${APP_ENV_VALUE}, logs -> ${LOGFILE}"
|
||||
|
||||
exec env APP_ENV="${APP_ENV_VALUE}" \
|
||||
gunicorn \
|
||||
-w "${GUNICORN_WORKERS}" \
|
||||
-k "${GUNICORN_WORKER_CLASS}" \
|
||||
-b "${APP_HOST}:${APP_PORT}" \
|
||||
--timeout "${GUNICORN_TIMEOUT}" \
|
||||
"${GUNICORN_MODULE}" \
|
||||
> >(tee -a "${LOGFILE}") \
|
||||
2> >(tee -a "${LOGFILE}" >&2)
|
||||
Reference in New Issue
Block a user