fix: 将 tpbig.exe 打包到 Docker 镜像中
- 新增 api/static/wine/ATP/tpbig.exe (1.3MB):从 atp-models 工程引入 - 新增 api/static/wine/atp/tpbig.exe (1.3MB):从 atp-models 工程引入 - 新增 api/docker-entrypoint.sh:容器启动时自动将 tpbig.exe 复制到 wine_allowed_root(/app/data/wine/) 的对应路径下,兼容 bind mount - 更新 api/Dockerfile:COPY static/ → /app/static/,设置 ENTRYPOINT 为 docker-entrypoint.sh 原理:Docker Compose 将 ./data/app 以 bind mount 挂载到 /app/data, 镜像中 /app/data 下的内容会被隐藏。通过 entrypoint 在启动时检查并 复制 tpbig.exe 到 bind mount 目录中,确保无论 volume 是否为空都能 正确初始化。
This commit is contained in:
@@ -27,7 +27,15 @@ COPY requirements.txt ./
|
|||||||
RUN pip install --no-cache-dir --retries "${PIP_RETRIES}" --timeout "${PIP_DEFAULT_TIMEOUT}" -i "${PIP_INDEX_URL}" -r requirements.txt
|
RUN pip install --no-cache-dir --retries "${PIP_RETRIES}" --timeout "${PIP_DEFAULT_TIMEOUT}" -i "${PIP_INDEX_URL}" -r requirements.txt
|
||||||
RUN python -c "import rasterio; print('rasterio ready:', rasterio.__version__)"
|
RUN python -c "import rasterio; print('rasterio ready:', rasterio.__version__)"
|
||||||
|
|
||||||
|
# Static assets (tpbig.exe, etc.)
|
||||||
|
COPY static/ /app/static/
|
||||||
|
|
||||||
|
# Entrypoint: ensures tpbig.exe is available in runtime volume
|
||||||
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
|
|
||||||
COPY app ./app
|
COPY app ./app
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--ws", "wsproto"]
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--ws", "wsproto"]
|
||||||
|
|||||||
Executable
+41
@@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# fquiz API Docker Entrypoint
|
||||||
|
# Ensures static assets (tpbig.exe) are available at runtime
|
||||||
|
# locations, even when the /app/data volume is a fresh bind mount.
|
||||||
|
# ============================================================
|
||||||
|
|
||||||
|
STATIC_ROOT="/app/static/wine"
|
||||||
|
DATA_ROOT="/app/data/wine"
|
||||||
|
|
||||||
|
# --- tpbig.exe (Legacy ATP path: wine_allowed_root/ATP/tpbig.exe) ---
|
||||||
|
if [ -f "${STATIC_ROOT}/ATP/tpbig.exe" ]; then
|
||||||
|
mkdir -p "${DATA_ROOT}/ATP"
|
||||||
|
if [ ! -f "${DATA_ROOT}/ATP/tpbig.exe" ] || ! cmp -s "${STATIC_ROOT}/ATP/tpbig.exe" "${DATA_ROOT}/ATP/tpbig.exe"; then
|
||||||
|
cp "${STATIC_ROOT}/ATP/tpbig.exe" "${DATA_ROOT}/ATP/tpbig.exe"
|
||||||
|
echo "entrypoint: initialized ${DATA_ROOT}/ATP/tpbig.exe"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- tpbig.exe (atp-storage path: used by atp_engine_executable) ---
|
||||||
|
if [ -f "${STATIC_ROOT}/atp/tpbig.exe" ]; then
|
||||||
|
mkdir -p "${DATA_ROOT}/atp"
|
||||||
|
if [ ! -f "${DATA_ROOT}/atp/tpbig.exe" ] || ! cmp -s "${STATIC_ROOT}/atp/tpbig.exe" "${DATA_ROOT}/atp/tpbig.exe"; then
|
||||||
|
cp "${STATIC_ROOT}/atp/tpbig.exe" "${DATA_ROOT}/atp/tpbig.exe"
|
||||||
|
echo "entrypoint: initialized ${DATA_ROOT}/atp/tpbig.exe"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- tpbig.exe (atp-models storage: atp_storage_root) ---
|
||||||
|
if [ -f "${STATIC_ROOT}/ATP/tpbig.exe" ]; then
|
||||||
|
mkdir -p "${DATA_ROOT}/atp-models"
|
||||||
|
if [ ! -f "${DATA_ROOT}/atp-models/tpbig.exe" ] || ! cmp -s "${STATIC_ROOT}/ATP/tpbig.exe" "${DATA_ROOT}/atp-models/tpbig.exe"; then
|
||||||
|
cp "${STATIC_ROOT}/ATP/tpbig.exe" "${DATA_ROOT}/atp-models/tpbig.exe"
|
||||||
|
echo "entrypoint: initialized ${DATA_ROOT}/atp-models/tpbig.exe"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Execute the main container command
|
||||||
|
exec "$@"
|
||||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user