Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
756633a
ADD - Implement CI workflow
Baptiiiiste Nov 12, 2025
7596bab
UPD - Refactor CI workflow to remove duplicate pnpm setup step
Baptiiiiste Nov 12, 2025
fad3091
UPD - Refactor CI workflow to remove duplicate pnpm setup step
Baptiiiiste Nov 12, 2025
89ba35e
UPD - Simplify request handling by directly using params.uuid
Baptiiiiste Nov 12, 2025
0751892
UPD - Simplify request handling by directly using params.uuid
Baptiiiiste Nov 12, 2025
c765ea6
UPD - Simplify request handling by directly using params.uuid
Baptiiiiste Nov 12, 2025
4696ea9
UPD - Simplify request handling by directly using params.uuid
Baptiiiiste Nov 12, 2025
b389c18
UPD - Update route parameter handling to use Promise for uuid extraction
Baptiiiiste Nov 12, 2025
2057906
UPD - Update route parameter handling to use Promise for uuid extraction
Baptiiiiste Nov 12, 2025
1bcd39e
UPD - Enhance CI configuration by adding Docker metadata extraction a…
Baptiiiiste Nov 12, 2025
7297256
UPD - Enhance CI configuration by adding Docker metadata extraction a…
Baptiiiiste Nov 12, 2025
901b0d6
UPD - Add step to generate Prisma Client in CI configuration
Baptiiiiste Nov 12, 2025
bae8dc4
UPD - Add step to generate Prisma Client in CI configuration
Baptiiiiste Nov 12, 2025
c147869
UPD - Update Dockerfile to generate Prisma Client and optimize produc…
Baptiiiiste Nov 14, 2025
0b94bd5
UPD - Update Dockerfile to generate Prisma Client and optimize produc…
Baptiiiiste Nov 14, 2025
e4245da
UPD - Refactor CI configuration to improve environment variable handl…
Baptiiiiste Nov 14, 2025
1ac38c5
UPD - Simplify CI configuration by removing environment input and dir…
Baptiiiiste Nov 14, 2025
ab3826f
UPD - Update CI configuration to enforce manual deployment conditions…
Baptiiiiste Nov 14, 2025
5a561ec
UPD - Add CI workflows for manual deployment to DEV and PROD environm…
Baptiiiiste Nov 14, 2025
3ee183e
UPD - Enhance CI configuration to support manual deployment to DEV an…
Baptiiiiste Nov 14, 2025
4458d99
UPD - CI
Baptiiiiste Nov 14, 2025
0f452e6
UPD - CI
Baptiiiiste Nov 14, 2025
611c28e
UPD - CI
Baptiiiiste Nov 14, 2025
9d4d434
UPD - CI
Baptiiiiste Nov 14, 2025
1b58d0c
UPD - CI
Baptiiiiste Nov 17, 2025
7065cb4
UPD - CI
Baptiiiiste Nov 17, 2025
a6ff91f
UPD - CI
Baptiiiiste Nov 17, 2025
24dfcb2
UPD - CI
Baptiiiiste Nov 17, 2025
cd4a6a5
UPD - CI
Baptiiiiste Nov 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 140 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: "DEV - CI/CD"

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
- main
workflow_dispatch:

jobs:
# 1️⃣ Build & tests
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Generate Prisma Client
run: pnpm prisma generate

- name: Skip tests (no test script defined)
run: echo "⚠️ Aucun test défini, étape ignorée."

- name: Build app
run: pnpm build


# 2️⃣ Build & push Docker image
docker-build-push:
runs-on: ubuntu-latest
needs: build-and-test
permissions:
contents: read
packages: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=sha,format=long

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
NEXT_PUBLIC_ENV=${{ github.base_ref }}


# 3️⃣ Deploy DEV
deploy-dev:
runs-on: self-hosted
needs: docker-build-push

steps:
- name: Clean workspace
run: rm -rf *

- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull new image + restart stack
run: |
echo "🔧 Deploying on the server..."
cd /home/baptiste/Dev/WPT/dev
docker-compose pull
docker rm -f wpt-dev_website || true
docker-compose up -d --remove-orphans
echo "🚀 Deployed in DEV!"

deploy-prod:
runs-on: self-hosted
needs: docker-build-push
if: github.ref == 'refs/heads/main'
steps:
- name: Clean workspace
run: rm -rf *

- name: Checkout code
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Pull new image + restart PROD stack
run: |
echo "🔧 Deploying on the server (PROD)..."
cd /home/baptiste/Dev/WPT/prod
docker-compose pull
docker rm -f wpt_website || true
docker-compose up -d --remove-orphans
echo "🚀 Deployed in PROD!"
80 changes: 65 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,74 @@
# Étape 1 : build
FROM node:22-alpine AS builder
FROM node:22-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat openssl
WORKDIR /app
RUN npm install -g pnpm

# Install pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate

# Install dependencies based on pnpm
COPY package.json pnpm-lock.yaml ./
COPY .env .env
RUN pnpm install
RUN pnpm install --frozen-lockfile

FROM base AS dev
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN apk add --no-cache openssl
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Generates prisma files
RUN pnpm prisma generate

# Enables Hot Reloading Check https://github.com/vercel/next.js/issues/36774 for more information
ENV CHOKIDAR_USEPOLLING=true
ENV WATCHPACK_POLLING=true

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
RUN corepack enable && corepack prepare pnpm@latest --activate
RUN apk add --no-cache openssl
COPY --from=deps /app/node_modules ./node_modules
COPY . .

ENV NEXT_TELEMETRY_DISABLED 1

# Generates prisma files for production build
RUN pnpm prisma generate
RUN pnpm build

# Étape 2 : image finale propre
FROM node:22-alpine
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
RUN npm install -g pnpm
COPY --from=builder /app/package.json /app/pnpm-lock.yaml ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.ts ./
COPY --from=builder /app/tsconfig.json ./

RUN pnpm install --prod
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN apk add --no-cache openssl
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# Install pnpm in runner
RUN corepack enable && corepack prepare pnpm@latest --activate

# Copier les fichiers nécessaires
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./
COPY --from=builder --chown=nextjs:nodejs /app/pnpm-lock.yaml ./
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma
COPY --from=builder --chown=nextjs:nodejs /app/next.config.ts ./

USER nextjs

EXPOSE 3000
CMD ["pnpm", "start"]
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"

# Prisma generate + db push + start
CMD sh -c "pnpm prisma generate && pnpm prisma db push --accept-data-loss && pnpm start"
16 changes: 8 additions & 8 deletions app/api/[uuid]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,50 +51,50 @@ async function handleRequest(req: NextRequest, uuid: string) {

export async function GET(
req: NextRequest,
{ params }: { params: { uuid: string } },
{ params }: { params: Promise<{ uuid: string }> },
) {
const { uuid } = await params
return handleRequest(req, uuid)
}
export async function POST(
req: NextRequest,
{ params }: { params: { uuid: string } },
{ params }: { params: Promise<{ uuid: string }> },
) {
const { uuid } = await params
return handleRequest(req, uuid)
}
export async function PUT(
req: NextRequest,
{ params }: { params: { uuid: string } },
{ params }: { params: Promise<{ uuid: string }> },
) {
const { uuid } = await params
return handleRequest(req, uuid)
}
export async function PATCH(
req: NextRequest,
{ params }: { params: { uuid: string } },
{ params }: { params: Promise<{ uuid: string }> },
) {
const { uuid } = await params
return handleRequest(req, uuid)
}
export async function DELETE(
req: NextRequest,
{ params }: { params: { uuid: string } },
{ params }: { params: Promise<{ uuid: string }> },
) {
const { uuid } = await params
return handleRequest(req, uuid)
}
export async function OPTIONS(
req: NextRequest,
{ params }: { params: { uuid: string } },
{ params }: { params: Promise<{ uuid: string }> },
) {
const { uuid } = await params
return handleRequest(req, uuid)
}
export async function HEAD(
req: NextRequest,
{ params }: { params: { uuid: string } },
{ params }: { params: Promise<{ uuid: string }> },
) {
const { uuid } = await params
return handleRequest(req, uuid)
}
}
55 changes: 0 additions & 55 deletions components/shared/breadcrumb/Breadcrumb.tsx

This file was deleted.

Loading