diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 00000000..fa99035f --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,21 @@ +name: Deploy Backendia + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: 📥 Récupération du code + uses: actions/checkout@v4 + + - name: 🚀 Build et Déploiement Docker + run: | + echo "🚀 Démarrage du déploiement..." + docker compose -f docker-compose.prod.yml up -d --build --remove-orphans + echo "🧹 Nettoyage des anciennes images inutilisées..." + docker image prune -f + echo "✅ Déploiement terminé avec succès !" diff --git a/backendia/.dockerignore b/backendia/.dockerignore new file mode 100644 index 00000000..c523a96e --- /dev/null +++ b/backendia/.dockerignore @@ -0,0 +1,8 @@ +node_modules +npm-debug.log* +dashboard/node_modules +dashboard/.next +uploads +exports +.git +.env* diff --git a/backendia/Dockerfile b/backendia/Dockerfile new file mode 100644 index 00000000..475ce8b4 --- /dev/null +++ b/backendia/Dockerfile @@ -0,0 +1,25 @@ +FROM node:20-bookworm-slim + +WORKDIR /app + +# Dépendances système pour les modules natifs (sharp, sqlite3, opencv) +RUN apt-get update && apt-get install -y --no-install-recommends \ + python3 \ + make \ + g++ \ + && rm -rf /var/lib/apt/lists/* + +COPY package*.json ./ +RUN npm ci --omit=dev + +COPY . . + +# Dossiers nécessaires +RUN mkdir -p uploads/images uploads/data exports + +EXPOSE 3000 + +ENV NODE_ENV=production +ENV PORT=3000 + +CMD ["node", "server.js"] diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 00000000..7867f486 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,19 @@ +services: + backendia: + build: + context: ./backendia + dockerfile: Dockerfile + container_name: backendia-prod + restart: unless-stopped + ports: + - "127.0.0.1:3000:3000" + environment: + - NODE_ENV=production + - PORT=3000 + volumes: + - backendia_uploads:/app/uploads + - backendia_exports:/app/exports + +volumes: + backendia_uploads: + backendia_exports: