fix(deploy): legg til Procfile + main.py for Cloud Run Buildpacks entrypoint

This commit is contained in:
chrischristiansen-glitch 2026-05-26 00:37:04 +02:00
parent 1e5400ab3a
commit 59d9859a48
2 changed files with 54 additions and 0 deletions

1
Procfile Normal file
View File

@ -0,0 +1 @@
web: gunicorn main:app --bind 0.0.0.0:$PORT --workers 1 --threads 8 --timeout 120

53
main.py Normal file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env python3
"""
main.py Cloud Run entrypoint for OSVauco OPAX agent.
Exposes a minimal Flask HTTP API that wraps agent.run().
"""
import os
import sys
# Ensure agents/core-logic is on the path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "agents", "core-logic"))
from flask import Flask, request, jsonify
from agent import run # agents/core-logic/agent.py
app = Flask(__name__)
@app.route("/health", methods=["GET"])
def health():
return jsonify({"status": "ok"})
@app.route("/run", methods=["POST"])
def run_agent():
body = request.get_json(force=True, silent=True) or {}
message = body.get("message", "")
user_id = body.get("user_id", "opax")
session_id = body.get("session_id", "default")
mode = body.get("mode", "A")
if not message:
return jsonify({"error": "'message' field required"}), 400
try:
response = run(
message=message,
user_id=user_id,
session_id=session_id,
mode=mode,
)
return jsonify({"response": response})
except PermissionError as e:
return jsonify({"error": str(e)}), 403
except ValueError as e:
return jsonify({"error": str(e)}), 400
except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == "__main__":
port = int(os.environ.get("PORT", 8080))
app.run(host="0.0.0.0", port=port)