update
This commit is contained in:
@@ -1,36 +1,129 @@
|
||||
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||
# Gaufrement Bon — site vitrine
|
||||
|
||||
## Getting Started
|
||||
Site vitrine et back-office pour **Gaufrement Bon** (gaufres artisanales à Bagnols-sur-Cèze) : page d’accueil, carte des gaufres, galerie photo, contenus éditables, et interface d’administration.
|
||||
|
||||
First, run the development server:
|
||||
## Fonctionnalités
|
||||
|
||||
- **Site public** : hero, menu par catégories (sucrées, salées, du mois), galerie, horaires et contact.
|
||||
- **Administration** (`/admin`) : connexion par session, gestion du menu, de la galerie et des textes / images du site.
|
||||
- **Upload d’images** : redimensionnement via Sharp, stockage dans `public/uploads/`.
|
||||
- **Base SQLite** : Prisma 7, migrations versionnées, seed au premier démarrage Docker.
|
||||
|
||||
## Stack
|
||||
|
||||
- [Next.js 15](https://nextjs.org) (App Router, Turbopack, sortie `standalone`)
|
||||
- React 19, Tailwind CSS 4
|
||||
- Prisma + SQLite (`better-sqlite3`)
|
||||
- Auth JWT en cookie (`jose`), rate limiting (mémoire ou [Upstash Redis](https://upstash.com))
|
||||
|
||||
## Prérequis
|
||||
|
||||
- Node.js 22+
|
||||
- npm
|
||||
|
||||
## Développement local
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npx prisma migrate deploy # crée dev.db si besoin
|
||||
npm run db:seed # optionnel : données de démo + compte admin
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
Ouvrir [http://localhost:3000](http://localhost:3000). L’admin est sur [http://localhost:3000/admin](http://localhost:3000/admin).
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
Sans fichier `.env`, les valeurs par défaut suivantes s’appliquent :
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||
| Variable | Défaut local |
|
||||
|----------|----------------|
|
||||
| `DATABASE_URL` | `file:./dev.db` |
|
||||
| `AUTH_SECRET` | secret de dev (à changer en prod) |
|
||||
| `ADMIN_EMAIL` | `admin@lagaufredor.local` |
|
||||
| `ADMIN_PASSWORD` | `changeme123` |
|
||||
|
||||
## Learn More
|
||||
Exemple `.env` :
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
```env
|
||||
DATABASE_URL="file:./dev.db"
|
||||
AUTH_SECRET="remplacer-par-une-longue-chaine-aleatoire"
|
||||
ADMIN_EMAIL="admin@example.com"
|
||||
ADMIN_PASSWORD="mot-de-passe-fort"
|
||||
# Optionnel — rate limiting distribué
|
||||
# UPSTASH_REDIS_REST_URL=
|
||||
# UPSTASH_REDIS_REST_TOKEN=
|
||||
```
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
## Scripts npm
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||
| Commande | Description |
|
||||
|----------|-------------|
|
||||
| `npm run dev` | Serveur de dev (port 3000) |
|
||||
| `npm run build` | Build production (migrations + generate Prisma) |
|
||||
| `npm run start` | Serveur Next en production |
|
||||
| `npm run db:seed` | Seed manuel (menu, galerie, contenus, admin) |
|
||||
| `npm run lint` | ESLint |
|
||||
|
||||
## Deploy on Vercel
|
||||
## Docker
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
Image publiée : `foufure/gauffre:latest`.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||
### Compose local (build + run)
|
||||
|
||||
```bash
|
||||
export AUTH_SECRET="$(openssl rand -base64 32)"
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
Application sur [http://localhost:3007](http://localhost:3007) (port hôte `3007` → conteneur `3000`).
|
||||
|
||||
Volumes : base SQLite (`gauffre-data`) et fichiers uploadés (`gauffre-uploads`).
|
||||
|
||||
### Déploiement serveur
|
||||
|
||||
Fichier dédié : `docker-compose.server.yml` (HTTPS assuré par Nginx + Certbot sur l’hôte).
|
||||
|
||||
```bash
|
||||
export AUTH_SECRET="$(openssl rand -base64 32)"
|
||||
export ADMIN_EMAIL="admin@example.com"
|
||||
export ADMIN_PASSWORD="mot-de-passe-fort"
|
||||
docker compose -f docker-compose.server.yml up -d
|
||||
```
|
||||
|
||||
Exemple de proxy Nginx : `proxy_pass http://127.0.0.1:3007;`
|
||||
Port hôte configurable via `HOST_PORT` (défaut `3007`).
|
||||
|
||||
Au démarrage du conteneur, `docker/entrypoint.sh` exécute les migrations Prisma et le seed, puis lance `node server.js`.
|
||||
|
||||
### Publier l’image sur Docker Hub
|
||||
|
||||
```bash
|
||||
docker login
|
||||
./scripts/docker-hub-push.sh # tag latest
|
||||
./scripts/docker-hub-push.sh v1.0.0 # tag personnalisé
|
||||
```
|
||||
|
||||
Variables optionnelles : `DOCKER_USER` (défaut `foufure`), `IMAGE_NAME` (défaut `gauffre`).
|
||||
|
||||
## Structure (aperçu)
|
||||
|
||||
```
|
||||
src/app/ # Pages et routes API (public + /admin)
|
||||
src/components/site/ # UI vitrine
|
||||
src/components/admin/ # UI back-office
|
||||
src/lib/ # Prisma, auth, uploads, contenus
|
||||
prisma/ # Schéma, migrations, seed
|
||||
public/gallery/ # Images statiques par défaut
|
||||
public/uploads/ # Images uploadées (persistées en Docker)
|
||||
docker/ # Entrypoint conteneur
|
||||
```
|
||||
|
||||
## Sécurité en production
|
||||
|
||||
- Définir un `AUTH_SECRET` long et aléatoire (`openssl rand -base64 32`).
|
||||
- Changer `ADMIN_EMAIL` et `ADMIN_PASSWORD` avant le premier seed, ou créer l’admin puis modifier le mot de passe.
|
||||
- Servir le site derrière HTTPS (Nginx ou équivalent).
|
||||
- Configurer Upstash si plusieurs instances partagent le rate limiting.
|
||||
|
||||
## Licence
|
||||
|
||||
Projet privé.
|
||||
|
||||
Reference in New Issue
Block a user