Run the project
What you need
- Node.js 22 and npm.
- A running API: locally (see Run the API) or the dev one.
Without Docker
sh
cd web
cp .env.example .env.local
npm ci
npm run devOpen http://localhost:3000. Also check http://localhost:3000/api/health, which must answer {"status":"ok"}.
The .env.local file holds the API address:
sh
# Copier ce fichier en .env.local pour le développement en local.
# Les vraies valeurs de dev et de prod sont dans les variables CI/CD GitLab.
# URL de l'API Django, vue depuis le serveur Next.js (pas depuis le navigateur).
API_URL=http://localhost:8000No API at hand?
Put the dev API in .env.local: API_URL=https://api.dev.trinity.jostud.com. The page will show the dev environment's products.
You are changing the dev products
With the dev API, adding or deleting from your machine really changes the dev database, shared with the whole team.
With Docker
From the repository root:
sh
# Dev: next dev, with the code mounted for hot reload
docker build -f web/Dockerfile.dev -t trinity-web:dev web
docker run -p 3000:3000 -e API_URL=http://host.docker.internal:8000 \
-v "$PWD/web":/app -v /app/node_modules -v /app/.next trinity-web:dev
# Prod: the exact image that goes to production
docker build -f web/Dockerfile.prod -t trinity-web:local web
docker run -p 3000:3000 -e API_URL=http://host.docker.internal:8000 trinity-web:localWhy -v /app/node_modules -v /app/.next? The web/ folder mounted into the container may have no node_modules. These two volumes stop the mount from hiding the ones installed in the image.
Useful commands
| Command | What it does |
|---|---|
npm run dev | Development server with |
npm test | Runs the tests |
npm run test:ci | Tests + coverage + JUnit report, as in the pipeline |
npm run lint | ESLint |
npm run build | Production build into .next/ |