Spaces:
Sleeping
Sleeping
Initial commit
Browse files- Dockerfile +23 -0
- app.py +25 -0
Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ===== Base Rocq + MathComp =====
|
| 2 |
+
FROM mathcomp/mathcomp-dev:rocq-prover-9.0
|
| 3 |
+
|
| 4 |
+
# ===== Install Coq-LSP + PET =====
|
| 5 |
+
RUN opam update && \
|
| 6 |
+
opam install -y logs lwt coq-lsp
|
| 7 |
+
|
| 8 |
+
# ===== Install Python + FastAPI =====
|
| 9 |
+
RUN apt-get update && apt-get install -y python3 python3-pip git curl && \
|
| 10 |
+
pip install --no-cache-dir fastapi uvicorn requests
|
| 11 |
+
|
| 12 |
+
# ===== Install pytanque from GitHub =====
|
| 13 |
+
RUN git clone https://github.com/LLM4Rocq/pytanque.git /tmp/pytanque && \
|
| 14 |
+
pip install -e /tmp/pytanque && \
|
| 15 |
+
rm -rf /tmp/pytanque
|
| 16 |
+
|
| 17 |
+
# ===== Copy App =====
|
| 18 |
+
WORKDIR /app
|
| 19 |
+
COPY app.py /app
|
| 20 |
+
|
| 21 |
+
EXPOSE 7861
|
| 22 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7861"]
|
| 23 |
+
|
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Request
|
| 2 |
+
from pytanque import Pytanque, PetanqueError
|
| 3 |
+
import subprocess, os, tempfile
|
| 4 |
+
|
| 5 |
+
app = FastAPI()
|
| 6 |
+
|
| 7 |
+
# Start PET server when container boots
|
| 8 |
+
PET_PORT = 8080
|
| 9 |
+
subprocess.Popen(["pet-server", "--port", str(PET_PORT)])
|
| 10 |
+
pet = Pytanque("127.0.0.1", PET_PORT)
|
| 11 |
+
pet.connect()
|
| 12 |
+
|
| 13 |
+
@app.get("/")
|
| 14 |
+
def health():
|
| 15 |
+
return {"status": "ok", "message": "Rocq backend running"}
|
| 16 |
+
|
| 17 |
+
@app.post("/check")
|
| 18 |
+
async def check_code(req: Request):
|
| 19 |
+
data = await req.json()
|
| 20 |
+
code = data.get("code", "")
|
| 21 |
+
try:
|
| 22 |
+
result = pet.eval(code)
|
| 23 |
+
except Exception as e:
|
| 24 |
+
result = f"Error: {e}"
|
| 25 |
+
return {"rocq_result": result}
|