From 3a8b2e26a335bd0ffe7a792087b1d68ff64972f6 Mon Sep 17 00:00:00 2001 From: Vincent Date: Thu, 2 Apr 2026 21:56:36 +0000 Subject: [PATCH] deployment --- .gitea/workflows/deploy.yml | 28 ++++++++++++++++++++++++++++ Dockerfile | 22 ++++++++++++++++++++++ requirements.txt | 5 +++++ 3 files changed, 55 insertions(+) create mode 100644 .gitea/workflows/deploy.yml create mode 100644 Dockerfile create mode 100644 requirements.txt diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..a2c59d9 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,28 @@ +name: Deploy-Test-API +run-name: ${{ gitea.actor }} is deploying the test API 🚀 + +on: + workflow_dispatch: + inputs: + target_env: + description: 'Environnement de destination' + required: true + default: 'production' + +jobs: + Deploy-To-VM: + # On demande à notre Runner Ubuntu de s'en occuper + runs-on: ubuntu-latest + steps: + - name: Vérification du statut + run: echo "Déploiement initié par ${{ gitea.actor }}." + + # On utilise directement la commande Docker de la VM hôte pour reconstruire et relancer + - name: Rebuild & Restart Test API + run: | + cd /home/ubuntu/n8n-stack + docker compose build test-api + docker compose up -d --no-deps test-api + + - name: Succès + run: echo "API redéployée avec succès !" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..12f01e9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# 1. On part d'une image Python légère +FROM python:3.11-slim + +# 2. On définit le dossier de travail dans le conteneur +WORKDIR /app + +# 3. On installe les dépendances système (pour Postgres/Valkey si besoin) +RUN apt-get update && apt-get install -y libpq-dev gcc && rm -rf /var/lib/apt/lists/* + +# 4. On copie et on installe les dépendances Python +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# 5. On copie tout ton code (dont main.py) dans le conteneur +COPY . . + +# 6. On expose le port sur lequel FastAPI va tourner +EXPOSE 9000 + +# 7. LA COMMANDE CRUCIALE : On lance le serveur Uvicorn +# On dit à Uvicorn de chercher l'objet "app" dans le fichier "main" +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "9000"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bd56e79 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +fastapi +uvicorn +langchain-google-genai +langgraph +# Ajoute ici les autres librairies que tu utilises dans ton code \ No newline at end of file