pyswisseph to rozszerzenie C, a na PyPI (2.10.3.2) gotowe wheels koncza sie na cp311 i obejmuja wylacznie i686/x86_64. Obraz stoi na python:3.12-slim, wiec pip ZAWSZE kompilowal ze zrodel - a slim nie ma kompilatora. Stad fail. - Dockerfile wieloetapowy: kompilacja w etapie builder (build-essential), do runtime trafia juz tylko gotowy wheel - obraz zostaje czysty i maly. Dziala tez na arm64, gdzie wheeli linuksowych nie ma dla zadnej wersji. - sanity check (import swisseph) na etapie builda, zeby niedzialajacy silnik wywracal build, a nie dopiero pierwszy request. - CI: nowy job swisseph-image - realny docker build + smoke test /health i /positions na horoskopie referencyjnym. - README: udokumentowany powod wieloetapowego builda. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit was merged in pull request #3.
This commit is contained in:
@@ -1,10 +1,34 @@
|
||||
# Build wieloetapowy — bo `pyswisseph` to rozszerzenie C bez gotowych wheeli.
|
||||
#
|
||||
# Na PyPI (2.10.3.2) wheels kończą się na cp311 i obejmują wyłącznie i686/x86_64.
|
||||
# Dla Pythona 3.12 oraz dla arm64 pip ZAWSZE kompiluje ze źródeł, a `-slim` nie ma
|
||||
# kompilatora — dlatego jednoetapowy build tu padał. Kompilujemy w etapie builder,
|
||||
# a do obrazu finalnego wchodzi już tylko gotowy wheel (bez toolchaina).
|
||||
|
||||
FROM python:3.12-slim AS builder
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends build-essential \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /build
|
||||
COPY requirements.txt .
|
||||
RUN pip wheel --no-cache-dir --wheel-dir /wheels -r requirements.txt
|
||||
|
||||
|
||||
FROM python:3.12-slim
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /wheels /wheels
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN pip install --no-cache-dir --no-index --find-links=/wheels -r requirements.txt \
|
||||
&& rm -rf /wheels
|
||||
|
||||
COPY . .
|
||||
|
||||
# Sanity check na etapie budowania: brak działającego swissepha ma wywalić build,
|
||||
# a nie dopiero pierwszy request.
|
||||
RUN python -c "import swisseph as swe; swe.set_ephe_path(None); print('swisseph OK', swe.version)"
|
||||
|
||||
EXPOSE 8003
|
||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8003"]
|
||||
|
||||
Reference in New Issue
Block a user