diff --git a/backend/Dockerfile b/backend/Dockerfile index 359d907..aa66886 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,5 @@ -FROM node:22-slim AS base +# syntax=docker/dockerfile:1 +FROM node:22-alpine AS base ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" RUN corepack enable && corepack prepare pnpm@latest --activate @@ -9,10 +10,17 @@ COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ COPY backend/package.json ./backend/ COPY frontend/package.json ./frontend/ COPY documentation/package.json ./documentation/ -RUN pnpm install --no-frozen-lockfile + +# Utilisation du cache pour pnpm et installation figée +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install --frozen-lockfile + COPY . . -# On réinstalle après COPY pour s'assurer que tous les scripts de cycle de vie et les liens sont corrects -RUN pnpm install --no-frozen-lockfile + +# Deuxième passe avec cache pour les scripts/liens +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install --frozen-lockfile + RUN pnpm run --filter @memegoat/backend build RUN pnpm deploy --filter=@memegoat/backend --prod --legacy /app RUN cp -r backend/dist /app/dist diff --git a/documentation/Dockerfile b/documentation/Dockerfile index d871966..003da53 100644 --- a/documentation/Dockerfile +++ b/documentation/Dockerfile @@ -1,4 +1,4 @@ -# syntax=docker.io/docker/dockerfile:1 +# syntax=docker/dockerfile:1 FROM node:22-alpine AS base ENV PNPM_HOME="/pnpm" @@ -11,11 +11,20 @@ COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ COPY backend/package.json ./backend/ COPY frontend/package.json ./frontend/ COPY documentation/package.json ./documentation/ -RUN pnpm install --no-frozen-lockfile + +# Montage du cache pnpm +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install --frozen-lockfile + COPY . . -# On réinstalle après COPY pour s'assurer que tous les scripts de cycle de vie et les liens sont corrects -RUN pnpm install --no-frozen-lockfile -RUN pnpm run --filter @memegoat/documentation build + +# Deuxième passe avec cache pour les scripts/liens +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install --frozen-lockfile + +# Build avec cache Next.js +RUN --mount=type=cache,id=next-docs-cache,target=/usr/src/app/documentation/.next/cache \ + pnpm run --filter @memegoat/documentation build FROM node:22-alpine AS runner WORKDIR /app diff --git a/frontend/Dockerfile b/frontend/Dockerfile index a26b050..e29df65 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,4 +1,4 @@ -# syntax=docker.io/docker/dockerfile:1 +# syntax=docker/dockerfile:1 FROM node:22-alpine AS base ENV PNPM_HOME="/pnpm" @@ -11,11 +11,20 @@ COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./ COPY backend/package.json ./backend/ COPY frontend/package.json ./frontend/ COPY documentation/package.json ./documentation/ -RUN pnpm install --no-frozen-lockfile + +# Montage du cache pnpm +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install --frozen-lockfile + COPY . . -# On réinstalle après COPY pour s'assurer que tous les scripts de cycle de vie et les liens sont corrects -RUN pnpm install --no-frozen-lockfile -RUN pnpm run --filter @memegoat/frontend build + +# Deuxième passe avec cache pour les scripts/liens +RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ + pnpm install --frozen-lockfile + +# Build avec cache Next.js +RUN --mount=type=cache,id=next-cache,target=/usr/src/app/frontend/.next/cache \ + pnpm run --filter @memegoat/frontend build FROM node:22-alpine AS runner WORKDIR /app