From ba5835866c4bb8ae2186e81648526492a745736e Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Fri, 19 Dec 2025 10:38:53 +0100 Subject: [PATCH] Update next.config.js for standalone output and enhance README with Docker instructions and installation updates --- .dockerignore | 62 +++++++++++++++++++++++++++++++++++++ .gitea/workflows/deploy.yml | 20 ++++++++++++ Dockerfile | 61 ++++++++++++++++++++++++++++++++++++ README.md | 37 +++++++++++++++++++--- docker-compose.yml | 28 +++++++++++++++++ next.config.js | 4 ++- public/.gitkeep | 0 7 files changed, 206 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitea/workflows/deploy.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 public/.gitkeep diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..770d1e8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,62 @@ +# Dependencies +node_modules +.pnpm-store +.pnpm-debug.log* + +# Next.js +.next +out +dist + +# Production +build + +# Misc +.DS_Store +*.pem + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Local env files +.env*.local +.env + +# Testing +coverage +.nyc_output + +# IDE +.vscode +.idea +*.swp +*.swo +*~ + +# Git +.git +.gitignore + +# Docker +Dockerfile +docker-compose.yml +.dockerignore + +# Documentation +README.md +*.md + +# Logs +logs +*.log + +# Temporary files +*.tmp +*.temp + +# CSV files +*.csv + diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..ceade21 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,20 @@ +name: Deploy with Docker Compose + +on: + push: + branches: + - main # adapte la branche que tu veux déployer + +jobs: + deploy: + runs-on: mac-orbstack-runner # le nom que tu as donné au runner + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Deploy stack + env: + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + run: | + docker compose up -d --build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..49dbd48 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,61 @@ +# Stage 1: Dependencies +FROM node:20-alpine AS deps +RUN apk add --no-cache libc6-compat +WORKDIR /app + +# Copy package files +COPY package.json pnpm-lock.yaml* ./ + +# Install pnpm if not available +RUN corepack enable && corepack prepare pnpm@latest --activate + +# Install dependencies +RUN pnpm install --frozen-lockfile + +# Stage 2: Builder +FROM node:20-alpine AS builder +WORKDIR /app + +# Copy dependencies from deps stage +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Enable pnpm +RUN corepack enable && corepack prepare pnpm@latest --activate + +# Set environment variable for build +ENV NEXT_TELEMETRY_DISABLED 1 + +# Create public directory if it doesn't exist +RUN mkdir -p public + +# Build the application +RUN pnpm run build + +# Stage 3: Runner +FROM node:20-alpine AS runner +WORKDIR /app + +ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +# Copy necessary files from builder +# Create public directory first +RUN mkdir -p ./public +# Copy public directory (will work now that we have public/.gitkeep in source) +COPY --from=builder --chown=nextjs:nodejs /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT 3000 +ENV HOSTNAME "0.0.0.0" + +CMD ["node", "server.js"] + diff --git a/README.md b/README.md index e091089..593149c 100644 --- a/README.md +++ b/README.md @@ -5,27 +5,54 @@ Application Next.js pour extraire aléatoirement un certain nombre de personnes ## Installation ```bash -npm install +pnpm install ``` ## Développement ```bash -npm run dev +pnpm dev ``` Ouvrez [http://localhost:3000](http://localhost:3000) dans votre navigateur. +## Docker + +### Build et lancement avec Docker Compose + +```bash +docker-compose up --build +``` + +L'application sera accessible sur [http://localhost:3000](http://localhost:3000) + +### Build manuel + +```bash +docker build -t people-randomizr . +docker run -p 3000:3000 people-randomizr +``` + +### Arrêter les conteneurs + +```bash +docker-compose down +``` + ## Fonctionnalités +- Upload de fichier CSV via l'interface +- Stockage des données dans le localStorage du navigateur - Affichage de toutes les personnes du CSV +- Filtrage par poste avec recherche - Extraction aléatoire d'un nombre configurable de personnes - Affichage des résultats avec nom, description et type +- Thème tech moderne avec glassmorphism ## Structure - `app/page.tsx` - Page principale avec l'interface utilisateur -- `app/api/people/route.ts` - API route pour charger les données du CSV -- `lib/csv-parser.ts` - Parser pour le fichier CSV -- `group-dev-ad.csv` - Fichier source des données +- `lib/csv-parser-client.ts` - Parser CSV côté client +- `Dockerfile` - Configuration Docker multi-stage +- `docker-compose.yml` - Configuration Docker Compose diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..13ba524 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +version: "3.8" + +services: + app: + build: + context: . + dockerfile: Dockerfile + container_name: people-randomizr + ports: + - "4399:3000" + environment: + - NODE_ENV=production + - NEXT_TELEMETRY_DISABLED=1 + restart: unless-stopped + healthcheck: + test: + [ + "CMD", + "wget", + "--quiet", + "--tries=1", + "--spider", + "http://localhost:3000", + ] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s diff --git a/next.config.js b/next.config.js index ccf1eb2..654de35 100644 --- a/next.config.js +++ b/next.config.js @@ -1,5 +1,7 @@ /** @type {import('next').NextConfig} */ -const nextConfig = {} +const nextConfig = { + output: 'standalone', +} module.exports = nextConfig diff --git a/public/.gitkeep b/public/.gitkeep new file mode 100644 index 0000000..e69de29