fix: failed to solve: process /bin/sh -c pip install --no-cache-dir -r requirements.txt did not complete successfully

This commit is contained in:
k
2026-04-21 19:49:47 +08:00
parent 3f901df82b
commit 0782aed4e6
2 changed files with 39 additions and 33 deletions
+21 -15
View File
@@ -1,34 +1,40 @@
FROM python:3.11-slim # ── Stage 1: build ───────────────────────────────────────────────────────────
# Compiles native extensions (ckzg, asyncpg, cryptography) so the final image
# only carries the compiled .so files, not the build toolchain.
FROM python:3.11-slim AS builder
# System deps needed for native extensions:
# gcc, libpq-dev → asyncpg (Postgres driver)
# libffi-dev → cryptography
# build-essential → general C compilation fallback
# curl → healthcheck probe
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
gcc build-essential libpq-dev libffi-dev curl \ gcc build-essential cmake libpq-dev libffi-dev \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /build
# Upgrade pip + install wheel first so pre-built wheels are preferred
RUN pip install --no-cache-dir --upgrade pip wheel setuptools RUN pip install --no-cache-dir --upgrade pip wheel setuptools
# Install Python deps (separate layer for cache efficiency)
COPY requirements.txt . COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# App source
# ── Stage 2: runtime ─────────────────────────────────────────────────────────
FROM python:3.11-slim
# Only runtime shared libs needed (libpq for asyncpg, libgomp for numpy if used)
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 curl \
&& rm -rf /var/lib/apt/lists/*
# Copy compiled packages from builder
COPY --from=builder /install /usr/local
WORKDIR /app
COPY . . COPY . .
# Make entrypoint executable
RUN chmod +x entrypoint.sh RUN chmod +x entrypoint.sh
# Non-root user for security # Non-root user
RUN useradd -m appuser && chown -R appuser /app RUN useradd -m appuser && chown -R appuser /app
USER appuser USER appuser
EXPOSE 8000 EXPOSE 8000
# Runs: alembic upgrade head → uvicorn
ENTRYPOINT ["./entrypoint.sh"] ENTRYPOINT ["./entrypoint.sh"]
+18 -18
View File
@@ -1,18 +1,18 @@
fastapi==0.111.0 fastapi==0.128.8
uvicorn[standard]==0.29.0 uvicorn[standard]==0.39.0
sqlalchemy[asyncio]==2.0.30 sqlalchemy[asyncio]==2.0.49
aiosqlite==0.20.0 aiosqlite==0.22.1
asyncpg==0.29.0 asyncpg==0.31.0
alembic==1.13.1 alembic==1.16.5
pydantic==2.7.1 pydantic==2.13.2
pydantic-settings==2.2.1 pydantic-settings==2.11.0
httpx==0.27.0 httpx==0.28.1
feedparser==6.0.11 feedparser==6.0.12
websockets==12.0 websockets==15.0.1
anthropic==0.28.0 anthropic==0.96.0
hyperliquid-python-sdk==0.8.0 hyperliquid-python-sdk==0.23.0
eth-account==0.11.0 eth-account==0.13.7
redis==5.0.4 redis==7.0.1
apscheduler==3.10.4 apscheduler==3.11.2
python-dotenv==1.0.1 python-dotenv==1.2.1
cryptography==42.0.8 cryptography==46.0.7