grok2api_B / Dockerfile
OwenPowell's picture
Update Dockerfile
aeed0ef verified
FROM ghcr.io/chenyme/grok2api:latest
ENV TZ=Asia/Shanghai \
LOG_LEVEL=DEBUG \
SERVER_PORT=8000
# 确保工作目录存在
WORKDIR /app
# 重新安装所有依赖(从 pyproject.toml)
RUN if [ -f /opt/venv/bin/activate ]; then \
. /opt/venv/bin/activate && \
if [ -f pyproject.toml ]; then \
pip install --no-cache-dir -e .; \
else \
pip install --no-cache-dir \
"aiofiles>=25.1.0" \
"aiohttp>=3.13.3" \
"aiohttp-socks>=0.11.0" \
"aiomysql>=0.2.0" \
"asyncpg>=0.31.0" \
"cryptography>=46.0.5" \
"curl-cffi>=0.13.0" \
"fastapi>=0.119.0" \
"granian>=2.7.2" \
"greenlet>=3.3.1" \
"livekit>=1.0.25" \
"loguru>=0.7.3" \
"orjson>=3.11.4" \
"python-dotenv>=1.0.0" \
"python-multipart>=0.0.21" \
"redis>=6.4.0" \
"sqlalchemy>=2.0.46" \
"websockets>=16.0" \
"uvicorn"; \
fi \
else \
if [ -f pyproject.toml ]; then \
pip3 install --no-cache-dir -e . || pip install --no-cache-dir -e .; \
else \
pip3 install --no-cache-dir \
"aiofiles>=25.1.0" \
"aiohttp>=3.13.3" \
"aiohttp-socks>=0.11.0" \
"aiomysql>=0.2.0" \
"asyncpg>=0.31.0" \
"cryptography>=46.0.5" \
"curl-cffi>=0.13.0" \
"fastapi>=0.119.0" \
"granian>=2.7.2" \
"greenlet>=3.3.1" \
"livekit>=1.0.25" \
"loguru>=0.7.3" \
"orjson>=3.11.4" \
"python-dotenv>=1.0.0" \
"python-multipart>=0.0.21" \
"redis>=6.4.0" \
"sqlalchemy>=2.0.46" \
"websockets>=16.0" \
"uvicorn" || \
pip install --no-cache-dir \
"aiofiles>=25.1.0" \
"aiohttp>=3.13.3" \
"aiohttp-socks>=0.11.0" \
"aiomysql>=0.2.0" \
"asyncpg>=0.31.0" \
"cryptography>=46.0.5" \
"curl-cffi>=0.13.0" \
"fastapi>=0.119.0" \
"granian>=2.7.2" \
"greenlet>=3.3.1" \
"livekit>=1.0.25" \
"loguru>=0.7.3" \
"orjson>=3.11.4" \
"python-dotenv>=1.0.0" \
"python-multipart>=0.0.21" \
"redis>=6.4.0" \
"sqlalchemy>=2.0.46" \
"websockets>=16.0" \
"uvicorn"; \
fi \
fi
# 创建必要的目录
RUN mkdir -p /app/data /app/logs && chmod -R 777 /app/data /app/logs
# 拷入并强制转换格式(解决 Windows 换行符导致的找不到文件报错)
COPY entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh
# 验证文件是否存在
RUN ls -la /entrypoint.sh && head -1 /entrypoint.sh
EXPOSE 8000
# 使用 shell 形式的 CMD,更兼容
CMD ["/bin/sh", "/entrypoint.sh"]