From 94126f05232d6f46f3e2af3a7b526378c547c992 Mon Sep 17 00:00:00 2001 From: Marcus Bohessef Date: Tue, 6 Jan 2026 20:41:16 -0300 Subject: [PATCH] ajuste no drone --- backoffice/Dockerfile | 55 ++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/backoffice/Dockerfile b/backoffice/Dockerfile index 0b9c2fb..bc88480 100644 --- a/backoffice/Dockerfile +++ b/backoffice/Dockerfile @@ -1,76 +1,58 @@ # ============================================================================= -# GoHorse Backoffice - Ultra-Optimized Dockerfile with pnpm -# Target: < 150MB final image, minimal disk usage during build +# GoHorse Backoffice - Ultra-Optimized Dockerfile # ============================================================================= -# syntax=docker/dockerfile:1 - -# ----------------------------------------------------------------------------- -# Stage 1: Base with pnpm -# ----------------------------------------------------------------------------- FROM mirror.gcr.io/library/node:20-alpine AS base -# Enable corepack and activate pnpm +# Configurações básicas e pnpm RUN corepack enable && corepack prepare pnpm@latest --activate - -# libc6-compat for native module compatibility RUN apk add --no-cache libc6-compat -# Set pnpm store for caching ENV PNPM_HOME="/pnpm" ENV PATH="$PNPM_HOME:$PATH" # ----------------------------------------------------------------------------- -# Stage 2: Dependencies +# Stage 1: Dependencies (Instalação real aqui) # ----------------------------------------------------------------------------- FROM base AS deps WORKDIR /app -# Copy package files +# Copia apenas os arquivos de definição COPY package.json pnpm-lock.yaml ./ -# Install with cache mount - reutiliza entre builds -#RUN --mount=type=cache,id=pnpm-backoffice,target=/pnpm/store \ -# pnpm install --frozen-lockfile --prefer-offline +# Instalamos as dependências de forma clássica (sem --mount para não quebrar no Drone) +RUN pnpm install --frozen-lockfile # ----------------------------------------------------------------------------- -# Stage 3: Builder (memory-optimized) +# Stage 2: Builder # ----------------------------------------------------------------------------- FROM base AS builder - -# Reduce memory for build -ENV NODE_OPTIONS="--max-old-space-size=2048" - WORKDIR /app -# Copy deps +ENV NODE_OPTIONS="--max-old-space-size=2048" + +# Copia os módulos instalados no estágio anterior COPY --from=deps /app/node_modules ./node_modules +COPY . . -# Copy source (selective, not COPY . .) -COPY package.json pnpm-lock.yaml ./ -COPY tsconfig*.json nest-cli.json ./ -COPY src ./src - -# Build and cleanup in same layer +# Build e limpeza de cache local do build RUN pnpm build && \ rm -rf node_modules/.cache -# Prune dev deps with cache -RUN --mount=type=cache,id=pnpm-backoffice,target=/pnpm/store \ - pnpm prune --prod && \ - pnpm store prune +# Remove dependências de desenvolvimento para diminuir a imagem final +# Removido --mount para compatibilidade com seu ambiente +RUN pnpm prune --prod # ----------------------------------------------------------------------------- -# Stage 4: Production (minimal) +# Stage 3: Production (Imagem Final Leve) # ----------------------------------------------------------------------------- FROM mirror.gcr.io/library/node:20-alpine AS runner -# Security: non-root user RUN addgroup -g 1001 -S nodejs && \ adduser -S nestjs -u 1001 -G nodejs WORKDIR /app -# Copy only production artifacts +# Copia apenas o necessário do estágio de build COPY --from=builder --chown=nestjs:nodejs /app/dist ./dist COPY --from=builder --chown=nestjs:nodejs /app/node_modules ./node_modules COPY --from=builder --chown=nestjs:nodejs /app/package.json ./ @@ -80,7 +62,6 @@ ENV NODE_ENV=production \ BACKOFFICE_HOST=0.0.0.0 USER nestjs - EXPOSE 3001 -CMD ["node", "dist/main.js"] +CMD ["node", "dist/main.js"] \ No newline at end of file