From 3fab15a93c488c420987262cf38735b9694192e2 Mon Sep 17 00:00:00 2001 From: streaper2 Date: Sat, 18 Apr 2026 22:32:05 +0200 Subject: [PATCH] correction deploiement --- .gitea/workflows/deploy.yaml | 9 ++++++-- Dockerfile | 41 ++++++++++++++++++++++++++++++------ docker-compose.yml | 2 ++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 9dfc6b8..294eee5 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -17,7 +17,12 @@ jobs: run: | echo "${{ secrets.TOKEN }}" | docker login git.home.arrondeau.fr -u ${{ gitea.actor }} --password-stdin - - name: Build and Push Docker Image + - name: Build and Push Docker Images run: | + # Build and Push FRONT docker build -t git.home.arrondeau.fr/${{ gitea.repository }}:latest . - docker push git.home.arrondeau.fr/${{ gitea.repository }}:latest \ No newline at end of file + docker push git.home.arrondeau.fr/${{ gitea.repository }}:latest + + # Build and Push ADMIN + docker build -t git.home.arrondeau.fr/${{ gitea.repository }}-admin:latest ./admin + docker push git.home.arrondeau.fr/${{ gitea.repository }}-admin:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index cc3d135..611e2c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,43 @@ -FROM node:20-alpine +# Étape 1 : Installation des dépendances +FROM node:20-alpine AS deps RUN apk add --no-cache libc6-compat openssl WORKDIR /app -# On copie tout, on installe tout, on build tout au même endroit +COPY package.json package-lock.json ./ +RUN npm ci + +# Étape 2 : Build de l'application +FROM node:20-alpine AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules COPY . . -RUN npm install + +# Variables d'environnement nécessaires pour le build +# (Prisma a besoin de DATABASE_URL pour npx prisma generate) +ENV NEXT_TELEMETRY_DISABLED 1 + RUN npx prisma generate RUN npm run build -EXPOSE 3000 +# Étape 3 : Image de production (Runner) +FROM node:20-alpine AS runner +WORKDIR /app -# On lance directement via npm -CMD ["npm", "start"] \ No newline at end of file +ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +# On ne copie que le nécessaire du build standalone +COPY --from=builder /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"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 645ec61..7fe27fd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,6 +20,7 @@ services: retries: 5 app: + image: git.home.arrondeau.fr/streaper2/afrov2:latest build: context: . dockerfile: Dockerfile @@ -35,6 +36,7 @@ services: condition: service_healthy admin: + image: git.home.arrondeau.fr/streaper2/afrov2-admin:latest build: context: ./admin dockerfile: Dockerfile