91 lines
1.9 KiB
Markdown
91 lines
1.9 KiB
Markdown
# Landing Server
|
|
|
|
Site Next.js pour les services de `leonmorival.xyz`.
|
|
|
|
## Minecraft whitelist
|
|
|
|
La page Minecraft contient un formulaire de candidature. Une demande valide envoie uniquement une notification dans le webhook configure avec :
|
|
|
|
- le pseudo Minecraft ;
|
|
- l'identifiant Discord renseigne ;
|
|
- le message du joueur.
|
|
|
|
Le site ne modifie pas directement la whitelist Minecraft.
|
|
|
|
Variable necessaire :
|
|
|
|
```bash
|
|
DISCORD_WHITELIST_WEBHOOK_URL="https://discord.com/api/webhooks/..."
|
|
```
|
|
|
|
## Developpement
|
|
|
|
```bash
|
|
npm install
|
|
npm run dev
|
|
```
|
|
|
|
Ouvre ensuite http://localhost:3000.
|
|
|
|
## Production Docker
|
|
|
|
Le plus simple sans CI/CD : le serveur clone le repo, puis Docker build et lance l'app.
|
|
|
|
```bash
|
|
git pull --ff-only
|
|
docker compose up -d --build
|
|
```
|
|
|
|
Le fichier `.env` du serveur doit contenir :
|
|
|
|
```bash
|
|
DISCORD_WHITELIST_WEBHOOK_URL="https://discord.com/api/webhooks/..."
|
|
```
|
|
|
|
Le conteneur expose l'app uniquement sur `127.0.0.1:3000`, pour la mettre derriere nginx.
|
|
|
|
## Auto-update simple
|
|
|
|
Le script [scripts/update-from-git-docker.sh](scripts/update-from-git-docker.sh) verifie si `origin/main` a un nouveau commit. Si oui, il fait :
|
|
|
|
```bash
|
|
git pull --ff-only
|
|
docker compose up -d --build --remove-orphans
|
|
```
|
|
|
|
Sur Ubuntu, tu peux l'appeler toutes les minutes avec un timer systemd :
|
|
|
|
```ini
|
|
# /etc/systemd/system/landing-server-update.service
|
|
[Unit]
|
|
Description=Update landing-server from Git
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
Environment=APP_DIR=/var/www/landing-server
|
|
Environment=BRANCH=main
|
|
ExecStart=/var/www/landing-server/scripts/update-from-git-docker.sh
|
|
```
|
|
|
|
```ini
|
|
# /etc/systemd/system/landing-server-update.timer
|
|
[Unit]
|
|
Description=Check landing-server Git updates
|
|
|
|
[Timer]
|
|
OnBootSec=2min
|
|
OnUnitActiveSec=1min
|
|
Persistent=true
|
|
|
|
[Install]
|
|
WantedBy=timers.target
|
|
```
|
|
|
|
Puis :
|
|
|
|
```bash
|
|
sudo chmod +x /var/www/landing-server/scripts/update-from-git-docker.sh
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable --now landing-server-update.timer
|
|
```
|