Aller au contenu

Installation and Local Development

Version française
Back to index


Prerequisites

Tool Minimum version Link
Node.js 18.0 https://nodejs.org
npm 9.0 (bundled with Node)
PostgreSQL 14.0 https://postgresql.org
MinIO Latest https://min.io
FFmpeg 4.0 https://ffmpeg.org
Git 2.x

Alternative to local installation: Docker Compose

If you have Docker, you can use the docker-compose.yml which includes pre-configured PostgreSQL and MinIO. See 08-deploiement.md.


1. Clone the repository

git clone https://gitlab.com/[organisation]/racines-app.git
cd racines-app

2. Install dependencies

npm install

3. Configure environment variables

cp .env.example .env.local  # If an example file exists
# Or create manually:
touch .env.local

Fill in .env.local with development values (see 02-variables-env.md):

# Local PostgreSQL
PG_HOST=localhost
PG_PORT=5432
PG_DATABASE=racines
PG_USER=postgres
PG_PASSWORD=postgres
PG_SSL=false

# Local MinIO
MINIO_ENDPOINT=localhost
MINIO_PORT=9000
MINIO_USE_SSL=false
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_BUCKET=audios
MINIO_PUBLIC_URL=http://localhost:9000

# Auth
JWT_SECRET=dev_secret_change_in_production

# Audio (in dev, proxy enabled because CDN_URL is empty)
AUDIO_CDN_URL=
AUDIO_PROXY_DISABLED=false

# PWA disabled in dev (avoids Service Worker conflicts)
NEXT_PUBLIC_PWA_ENABLED=false

4. Initialize PostgreSQL

Create the database

# Connect to PostgreSQL
psql -U postgres

# Create the database and user
CREATE DATABASE racines;
\q

Run migrations

# From the project root
psql -U postgres -d racines -f migrations/001_initial_schema.sql
psql -U postgres -d racines -f migrations/002_create_admins.sql
psql -U postgres -d racines -f migrations/004_quiz_results.sql

Note: migrations/003_idb_card_id_index_note.sql is a documentation note, not a SQL migration to execute.


5. Configure MinIO

docker run -d \
  --name minio \
  -p 9000:9000 \
  -p 9001:9001 \
  -e MINIO_ROOT_USER=minioadmin \
  -e MINIO_ROOT_PASSWORD=minioadmin \
  minio/minio server /data --console-address ":9001"

Create the audios bucket

# Via the MinIO web interface: http://localhost:9001
# Login: minioadmin / minioadmin
# Create a bucket named "audios" with "public" policy

# Or via CLI (mc):
mc alias set local http://localhost:9000 minioadmin minioadmin
mc mb local/audios
mc anonymous set public local/audios
mc version enable local/audios

6. Create the first administrator account

npm run create-admin
# Follow the prompts:
# Email: admin@racines.local
# Password: [your_password]
# Confirmation: [your_password]

7. Start the development server

npm run dev

The application is accessible at http://localhost:3000.


Local URLs

URL Description
http://localhost:3000 Racines application
http://localhost:3000/admin Admin interface
http://localhost:3000/speaker/login Speaker interface
http://localhost:9001 MinIO console (admin)

Available npm scripts

Command Description
npm run dev Start in development mode (hot reload)
npm run build Production build
npm run start Start in production mode (after build)
npm run lint ESLint check
npm run create-admin Create an administrator account

Testing the installation

# 1. Verify the app starts without errors
npm run dev
# → The application should start at http://localhost:3000

# 2. Check the health endpoint
curl http://localhost:3000/api/health/live
# → {"status":"ok","timestamp":"..."}

# 3. Verify the PostgreSQL connection
curl http://localhost:3000/api/languages
# → [] (empty list if no language has been created)

# 4. Log in as admin
# → Go to http://localhost:3000/admin and sign in

Development with Docker Compose (alternative)

If you prefer Docker for PostgreSQL and MinIO:

# Start only the database and storage
docker-compose up -d postgres minio minio-init

# Then develop with Next.js locally
npm run dev

Next steps