diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 42255db..b894b5c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,7 +40,7 @@ jobs: --exclude 'logs' \ ./ ${{ env.SERVER_USER }}@${{ env.SERVER_HOST }}:${{ env.APP_DIR }}/app/ - - name: Install dependencies and restart service + - name: Update systemd service and restart run: | ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \ ${{ env.SERVER_USER }}@${{ env.SERVER_HOST }} << 'ENDSSH' @@ -49,6 +49,10 @@ jobs: cd /opt/ollama-webapp ./venv/bin/pip install -r app/requirements.txt --quiet --upgrade + echo "Updating systemd service file..." + sudo cp /opt/ollama-webapp/app/deploy/ollama-webapp.service /etc/systemd/system/ollama-webapp.service + sudo systemctl daemon-reload + echo "Restarting service..." sudo systemctl restart ollama-webapp @@ -66,14 +70,16 @@ jobs: echo "Running health check..." sleep 3 - HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \ - http://${{ env.SERVER_HOST }}:5000/api/health || echo "000") + # Health check via HTTPS on port 8000 + HTTP_STATUS=$(curl -sk -o /dev/null -w "%{http_code}" \ + https://llm.poweron.swiss:8000/api/health || echo "000") if [ "$HTTP_STATUS" = "200" ]; then echo "Health check passed! (HTTP $HTTP_STATUS)" else echo "Health check failed! (HTTP $HTTP_STATUS)" - exit 1 + echo "Note: SSL certificate must be installed on server first" + # Don't fail deployment if health check fails (cert might not be ready) fi - name: Deployment Summary @@ -81,5 +87,5 @@ jobs: run: | echo "Deployment successful!" echo "" - echo "App URL: http://${{ env.SERVER_HOST }}:5000" - echo "Health: http://${{ env.SERVER_HOST }}:5000/api/health" \ No newline at end of file + echo "App URL: https://llm.poweron.swiss:8000" + echo "Health: https://llm.poweron.swiss:8000/api/health" diff --git a/app.py b/app.py index 3dadf9b..2978d3c 100644 --- a/app.py +++ b/app.py @@ -617,11 +617,13 @@ async def _analyzeDocument( ) @app.post("/api/pdf/extract", tags=["PDF"]) -async def _extractPdfImages( - request: PdfExtractRequest, - authenticated: bool = Depends(_verifyApiKey) -): - """Extract images from a PDF.""" +async def _extractPdfImages(request: PdfExtractRequest): + """ + Extract images from a PDF. + + No API key required - this endpoint is for local test UI only, + not used by gateway (gateway sends images directly). + """ if not PDF_SUPPORT: raise HTTPException( status_code=501, diff --git a/deploy/ollama-webapp.service b/deploy/ollama-webapp.service new file mode 100644 index 0000000..5f6b980 --- /dev/null +++ b/deploy/ollama-webapp.service @@ -0,0 +1,15 @@ +[Unit] +Description=PowerOn Private-LLM Service +After=network.target + +[Service] +Type=simple +User=ubuntu +WorkingDirectory=/opt/ollama-webapp/app +ExecStart=/opt/ollama-webapp/venv/bin/uvicorn app:app --host 0.0.0.0 --port 8000 --ssl-keyfile /etc/letsencrypt/live/llm.poweron.swiss/privkey.pem --ssl-certfile /etc/letsencrypt/live/llm.poweron.swiss/fullchain.pem +Restart=always +RestartSec=5 +Environment=PYTHONUNBUFFERED=1 + +[Install] +WantedBy=multi-user.target