|
|
|
|
|
FROM python:3.9-slim |
|
|
|
|
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \ |
|
|
openjdk-21-jre-headless \ |
|
|
libxrender1 \ |
|
|
libxext6 \ |
|
|
libstdc++6 \ |
|
|
locales \ |
|
|
gcc \ |
|
|
python3-dev \ |
|
|
&& rm -rf /var/lib/apt/lists/* |
|
|
|
|
|
|
|
|
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ |
|
|
locale-gen |
|
|
ENV LANG=en_US.UTF-8 \ |
|
|
LANGUAGE=en_US:en \ |
|
|
LC_ALL=en_US.UTF-8 |
|
|
|
|
|
|
|
|
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 \ |
|
|
PATH=$JAVA_HOME/bin:$PATH \ |
|
|
TF_ENABLE_ONEDNN_OPTS=1 \ |
|
|
TF_CPP_MIN_LOG_LEVEL=2 \ |
|
|
|
|
|
LD_BIND_NOW=1 \ |
|
|
|
|
|
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 \ |
|
|
HOME=/home/user |
|
|
|
|
|
|
|
|
RUN useradd -m -u 1000 user |
|
|
USER user |
|
|
WORKDIR /home/user/app |
|
|
ENV PATH=/home/user/.local/bin:$PATH |
|
|
|
|
|
|
|
|
RUN pip install --no-cache-dir wheel && \ |
|
|
pip install --no-cache-dir \ |
|
|
intel-tensorflow \ |
|
|
fastapi uvicorn gunicorn STOUT-pypi rdkit-pypi "numpy<2.0" |
|
|
|
|
|
|
|
|
RUN cat <<EOF > app.py |
|
|
import os |
|
|
import uvicorn |
|
|
from fastapi import FastAPI, HTTPException, Body |
|
|
from STOUT import translate_forward, translate_reverse |
|
|
from rdkit import Chem |
|
|
from typing import List |
|
|
|
|
|
app = FastAPI(title="STOUT V2 SIGSEGV-Fixed API") |
|
|
|
|
|
|
|
|
def clean_smi(s): |
|
|
try: |
|
|
m = Chem.MolFromSmiles(s) |
|
|
return Chem.MolToSmiles(m, isomericSmiles=True) if m else None |
|
|
except: return None |
|
|
|
|
|
@app.get("/") |
|
|
def root(): return {"message": "STOUT V2 - Stable Build"} |
|
|
|
|
|
@app.api_route("/smiles_to_iupac", methods=["GET", "POST"]) |
|
|
def s2i(smiles: str): |
|
|
s = clean_smi(smiles) |
|
|
if not s: raise HTTPException(400, "Invalid SMILES") |
|
|
return {"iupac": translate_forward(s)} |
|
|
|
|
|
@app.get("/health") |
|
|
def health(): return {"status": "healthy"} |
|
|
|
|
|
if __name__ == "__main__": |
|
|
uvicorn.run(app, host="0.0.0.0", port=7860) |
|
|
EOF |
|
|
|
|
|
|
|
|
EXPOSE 7860 |
|
|
|
|
|
|
|
|
CMD ["gunicorn", "app:app", \ |
|
|
"--workers", "3", \ |
|
|
"--worker-class", "uvicorn.workers.UvicornWorker", \ |
|
|
"--bind", "0.0.0.0:7860", \ |
|
|
"--timeout", "300"] |