25.09.16 update
parent
96a975b9ad
commit
c5dd60a82d
|
@ -16,6 +16,11 @@ venv/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
# 忽略指定目录
|
# 忽略指定目录
|
||||||
|
.vscode/
|
||||||
data/
|
data/
|
||||||
logs/
|
logs/
|
||||||
conf/
|
conf/
|
||||||
|
Dockerfile
|
||||||
|
docker-compose.yml
|
||||||
|
README.md
|
||||||
|
LICENSE
|
||||||
|
|
25
Dockerfile
25
Dockerfile
|
@ -1,36 +1,19 @@
|
||||||
FROM python:3.13-slim AS builder
|
FROM python:3.13-slim AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
|
RUN pip wheel --no-cache-dir --wheel-dir /app/wheels -r requirements.txt
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN python -m compileall -b . && find . -name "*.py" -delete
|
||||||
|
|
||||||
RUN python -m compileall -b .
|
|
||||||
|
|
||||||
FROM python:3.13-slim
|
FROM python:3.13-slim
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=builder /app/wheels /wheels
|
|
||||||
COPY --from=builder /app/requirements.txt .
|
|
||||||
RUN pip install --no-cache /wheels/*
|
|
||||||
|
|
||||||
COPY --from=builder /app /app
|
COPY --from=builder /app /app
|
||||||
|
RUN pip install --no-cache /app/wheels/* && chmod +x /app/entrypoint.sh && rm -rf /wheels /app/wheels
|
||||||
RUN find . -type d -name "__pycache__" | while read -r dir; do \
|
|
||||||
module_dir=$(dirname "$dir"); \
|
|
||||||
mv "$dir"/*.pyc "$module_dir/"; \
|
|
||||||
rmdir "$dir"; \
|
|
||||||
done
|
|
||||||
|
|
||||||
RUN find . -name "*.py" -delete
|
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
VOLUME ["/app/data", "/app/logs"]
|
||||||
VOLUME ["/app/data", "/app/conf", "/app/logs"]
|
|
||||||
|
|
||||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|
||||||
CMD ["gunicorn", "-c", "conf/gunicorn.conf.py", "main:app"]
|
CMD ["gunicorn", "-c", "conf/gunicorn.conf.py", "main:app"]
|
||||||
|
|
|
@ -10,12 +10,12 @@ logging_conf="/app/conf/logging.yaml"
|
||||||
|
|
||||||
if [ ! -f "$gunicorn_conf" ]; then
|
if [ ! -f "$gunicorn_conf" ]; then
|
||||||
echo "复制 gunicorn.conf.py..."
|
echo "复制 gunicorn.conf.py..."
|
||||||
if [ -f "$default_conf_dir/gunicorn_conf_py" ]; then
|
if [ -f "${default_conf_dir}/gunicorn_conf_py" ]; then
|
||||||
cp "$default_conf_dir/gunicorn_conf_py" "$gunicorn_conf"
|
cp "${default_conf_dir}/gunicorn_conf_py" "$gunicorn_conf"
|
||||||
chmod 644 "$gunicorn_conf"
|
chmod 644 "$gunicorn_conf"
|
||||||
echo "复制 gunicorn.conf.py 成功"
|
echo "复制 gunicorn.conf.py 成功"
|
||||||
else
|
else
|
||||||
echo "警告:默认配置文件 $default_conf_dir/gunicorn_conf_py 不存在,创建空文件"
|
echo "警告:默认配置文件 ${default_conf_dir}/gunicorn_conf_py 不存在,创建空文件"
|
||||||
touch "$gunicorn_conf"
|
touch "$gunicorn_conf"
|
||||||
chmod 644 "$gunicorn_conf"
|
chmod 644 "$gunicorn_conf"
|
||||||
fi
|
fi
|
||||||
|
@ -23,17 +23,25 @@ fi
|
||||||
|
|
||||||
if [ ! -f "$logging_conf" ]; then
|
if [ ! -f "$logging_conf" ]; then
|
||||||
echo "复制 logging.yaml..."
|
echo "复制 logging.yaml..."
|
||||||
if [ -f "$default_conf_dir/logging.yaml" ]; then
|
if [ -f "${default_conf_dir}/logging.yaml" ]; then
|
||||||
cp "$default_conf_dir/logging.yaml" "$logging_conf"
|
cp "${default_conf_dir}/logging.yaml" "$logging_conf"
|
||||||
chmod 644 "$logging_conf"
|
chmod 644 "$logging_conf"
|
||||||
echo "复制 logging.yaml 成功"
|
echo "复制 logging.yaml 成功"
|
||||||
else
|
else
|
||||||
echo "警告:默认配置文件 $default_conf_dir/logging.yaml 不存在,创建空文件"
|
echo "警告:默认配置文件 ${default_conf_dir}/logging.yaml 不存在,创建空文件"
|
||||||
touch "$logging_conf"
|
touch "$logging_conf"
|
||||||
chmod 644 "$logging_conf"
|
chmod 644 "$logging_conf"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /app/logs /app/data
|
if [ ! -d "/app/logs" ]; then
|
||||||
|
mkdir -p /app/logs
|
||||||
|
chmod 755 /app/logs
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/app/data" ]; then
|
||||||
|
mkdir -p /app/data
|
||||||
|
chmod 755 /app/data
|
||||||
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
--index https://mirrors.xinac.net/pypi/simple
|
--index https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
--extra-index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
--extra-index-url https://mirrors.xinac.net/pypi/simple
|
||||||
|
--trusted-host pypi.tuna.tsinghua.edu.cn
|
||||||
|
--trusted-host mirrors.aliyun.com
|
||||||
|
--trusted-host mirrors.xinac.net
|
||||||
|
|
||||||
fastapi~=0.116.1
|
fastapi~=0.116.1
|
||||||
pydantic~=2.11.7
|
|
||||||
pydantic_core~=2.33.2
|
|
||||||
starlette~=0.47.3
|
|
||||||
requests~=2.32.5
|
requests~=2.32.5
|
||||||
aiohttp~=3.12.15
|
aiohttp~=3.12.15
|
||||||
bs4~=0.0.2
|
bs4~=0.0.2
|
||||||
beautifulsoup4~=4.13.5
|
|
||||||
lxml~=6.0.1
|
lxml~=6.0.1
|
||||||
PyYAML~=6.0.2
|
PyYAML~=6.0.2
|
||||||
uvicorn~=0.35.0
|
uvicorn~=0.35.0
|
||||||
|
|
Loading…
Reference in New Issue