33800 Docs

← Retour

Proposition : Mini Projet Pizza

Date : 30-12-2025 22:15 Statut : En attente de validation


Objectif

Créer un mini projet "pizza" qui affiche une page avec le titre "Pizza", hébergé sur GitHub, développé sur vscode.local, et exposé sur pizza.test.nowhere84.com.


Stack choisie

Composant Choix Justification
Runtime Bun 1.3.5 (baseline) Déjà installé sur vscode.local, rapide
Framework Elysia Léger, parfait pour un mini projet
Hébergement code GitHub Comme demandé
Déploiement prod-portainer Docker avec shortcut bun

Étapes de réalisation

1. Création repo GitHub

# Créer repo gouroubleu/pizza sur GitHub
gh repo create gouroubleu/pizza --public --description "Mini projet Pizza"

2. Développement sur vscode.local

# Cloner et initialiser
cd ~/WS
git clone https://github.com/gouroubleu/pizza.git
cd pizza

# Init Bun + Elysia
~/.bun/bin/bun init
~/.bun/bin/bun add elysia @elysiajs/html

# Créer src/index.ts avec page Pizza

Code prévu (src/index.ts) :

import { Elysia } from 'elysia';
import { html } from '@elysiajs/html';

const app = new Elysia()
  .use(html())
  .get('/', () => `
    <!DOCTYPE html>
    <html>
      <head>
        <title>Pizza</title>
        <style>
          body {
            font-family: system-ui;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background: linear-gradient(135deg, #ff6b6b, #ffa502);
          }
          h1 {
            font-size: 5rem;
            color: white;
            text-shadow: 3px 3px 0 #c0392b;
          }
        </style>
      </head>
      <body>
        <h1>Pizza</h1>
      </body>
    </html>
  `)
  .listen(3000);

console.log(`Pizza server running at http://localhost:${app.server?.port}`);

3. Création wildcard DNS

# Ajouter *.test.nowhere84.com → 82.65.119.221
/mnt/stock_36to/data/33800-stack/scripts/dns/add-wildcard.sh test

Résultat : *.test.nowhere84.com pointera vers Nginx (82.65.119.221)

4. Configuration Nginx

Créer /etc/nginx/sites-available/pizza.test.nowhere84.com :

server {
    listen 443 ssl http2;
    server_name pizza.test.nowhere84.com;

    ssl_certificate /etc/letsencrypt/live/33800.nowhere84.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/33800.nowhere84.com/privkey.pem;

    location / {
        proxy_pass http://192.168.1.11:3100;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Note : Il faudra peut-être générer un nouveau certificat SSL pour *.test.nowhere84.com ou utiliser un certificat existant.

5. Déploiement Docker sur prod-portainer

# Build et run
docker build -t pizza:prod .
docker run -d --name pizza-prod -p 3100:3000 pizza:prod

Ports utilisés

Service Port interne Port exposé URL
pizza 3000 3100 pizza.test.nowhere84.com

Questions à valider

  1. SSL : Utiliser le certificat wildcard existant (33800.nowhere84.com) ou en créer un nouveau pour *.test.nowhere84.com ?

    • Option A : Réutiliser le cert existant (fonctionnera mais warning navigateur possible)
    • Option B : Créer nouveau cert Let's Encrypt pour *.test.nowhere84.com
  2. Environnement : Déployer sur PROD (prod-portainer) ou DEV (dev-portainer) ?


Fichiers à créer

pizza/
├── src/
│   └── index.ts
├── Dockerfile
├── package.json
├── tsconfig.json
└── README.md

Commandes récapitulatives

# 1. Créer repo GitHub
gh repo create gouroubleu/pizza --public

# 2. Dev sur vscode.local
ssh gouroubleu@vscode.local
cd ~/WS && git clone ... && cd pizza
~/.bun/bin/bun init && ~/.bun/bin/bun add elysia @elysiajs/html

# 3. DNS
/mnt/stock_36to/data/33800-stack/scripts/dns/add-wildcard.sh test

# 4. Nginx config + SSL
ssh gouroubleu@nginx.local "sudo certbot certonly --nginx -d '*.test.nowhere84.com'"

# 5. Deploy
docker build -t pizza:prod . && docker run -d --name pizza-prod -p 3100:3000 pizza:prod

En attente de ta validation pour lancer l'exécution.