Skip to content

Commit 1bf303a

Browse files
committed
chore(deploy): vps-monitor
1 parent 6777a25 commit 1bf303a

4 files changed

Lines changed: 50 additions & 59 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'Deploy to VPS'
1+
name: Deploy to VPS
22

33
on:
44
push:
@@ -7,64 +7,14 @@ on:
77

88
jobs:
99
deploy:
10-
name: 'Déploiement SaintBarth Volley'
10+
name: Déploiement SaintBarth Volley
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- name: 'Checkout code'
15-
uses: actions/checkout@v4
16-
17-
- name: 'Deploy via SSH'
18-
uses: appleboy/ssh-action@v1.0.3
19-
with:
20-
host: ${{ secrets.VPS_HOST }}
21-
username: ${{ secrets.VPS_USER }}
22-
key: ${{ secrets.VPS_SSH_KEY }}
23-
port: 22
24-
command_timeout: 30m
25-
script: |
26-
set -e
27-
echo "🚀 Déploiement SaintBarth Volley"
28-
29-
REPO_DIR="/var/www/SaintBarthVolley"
30-
COMPOSE_FILE="/var/www/docker-compose.yml"
31-
32-
# ── Cloner ou mettre à jour le repo ──────────────────────────
33-
if [ ! -d "$REPO_DIR/.git" ]; then
34-
echo "📥 Premier déploiement — clonage du repo..."
35-
git clone https://github.com/${{ github.repository }}.git "$REPO_DIR"
36-
else
37-
echo "🔄 Mise à jour du code..."
38-
git -C "$REPO_DIR" fetch origin main
39-
git -C "$REPO_DIR" reset --hard origin/main
40-
fi
41-
echo "✅ Code à jour"
42-
43-
# ── Vérifier que le .env backend existe ───────────────────────
44-
ENV_FILE="$REPO_DIR/saintBarthVolleyApp/backend/.env"
45-
if [ ! -f "$ENV_FILE" ]; then
46-
echo "❌ Fichier .env manquant : $ENV_FILE"
47-
echo " Créez-le depuis .env.example avant de déployer."
48-
exit 1
49-
fi
50-
echo "✅ Fichier .env backend trouvé"
51-
52-
# ── Rebuild et restart uniquement les services SaintBarth ─────
53-
echo "🔨 Build des images..."
54-
docker-compose -f "$COMPOSE_FILE" build sbv-api sbv-front
55-
56-
echo "🔄 Redémarrage des containers..."
57-
docker-compose -f "$COMPOSE_FILE" up -d --remove-orphans sbv-api sbv-front
58-
59-
echo "✅ Containers démarrés"
60-
61-
# ── Nettoyage des images obsolètes ────────────────────────────
62-
docker image prune -f
63-
64-
# ── Vérification finale ───────────────────────────────────────
65-
echo ""
66-
echo "📊 État des containers SaintBarth :"
67-
docker ps --filter "name=sbv-" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
68-
69-
echo ""
70-
echo "🎉 Déploiement terminé !"
14+
- name: Trigger deploy via vps-monitor
15+
run: |
16+
curl -f -s -X POST "${{ secrets.VPS_MONITOR_URL }}/api/webhook/deploy" \
17+
-H "Authorization: Bearer ${{ secrets.WEBHOOK_SECRET }}" \
18+
-H "Content-Type: application/json" \
19+
-d '{"name": "sbv"}' \
20+
| grep -q '"ok":true' || { echo "Échec déploiement vps-monitor"; exit 1; }

deployment/docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
services:
2+
sbv-front:
3+
image: sbv-front:latest
4+
build:
5+
context: ../saintBarthVolleyApp/frontend
6+
dockerfile: Dockerfile
7+
args:
8+
NEXT_BASE_PATH: /saintbarthvolley
9+
NEXT_PUBLIC_API_URL: /saintbarthvolley
10+
BACKEND_URL: http://sbv-api:5000
11+
restart: unless-stopped
12+
ports:
13+
- "127.0.0.1:3001:3000"
14+
depends_on:
15+
- sbv-api
16+
17+
sbv-api:
18+
image: sbv-api:latest
19+
build:
20+
context: ../saintBarthVolleyApp/backend
21+
dockerfile: Dockerfile
22+
restart: unless-stopped
23+
env_file: .env
24+
environment:
25+
NODE_ENV: production
26+
PORT: "5000"

saintBarthVolleyApp/frontend/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ WORKDIR /usr/src/app
66
# Build args passés par docker-compose
77
ARG NEXT_BASE_PATH="/saintbarthvolley"
88
ARG NEXT_PUBLIC_API_URL="http://localhost:5000"
9+
ARG BACKEND_URL="http://localhost:5000"
910

1011
ENV NEXT_BASE_PATH=$NEXT_BASE_PATH
1112
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
13+
ENV BACKEND_URL=$BACKEND_URL
1214

1315
COPY package*.json ./
1416
RUN npm install

saintBarthVolleyApp/frontend/next.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import type { NextConfig } from "next";
22

33
const basePath = process.env.NEXT_BASE_PATH || "";
4+
const backendUrl = process.env.BACKEND_URL || "http://localhost:5000";
45

56
const nextConfig: NextConfig = {
67
output: "standalone",
78
basePath,
89
trailingSlash: true,
10+
async rewrites() {
11+
return [
12+
{
13+
source: "/api/:path*",
14+
destination: `${backendUrl}/api/:path*`,
15+
},
16+
{
17+
source: "/uploads/:path*",
18+
destination: `${backendUrl}/uploads/:path*`,
19+
},
20+
];
21+
},
922
images: {
1023
remotePatterns: [
1124
{

0 commit comments

Comments
 (0)