diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 06aad8e..723abc3 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -79,9 +79,6 @@ jobs: - id: plano run: scripts/plano-imagem.sh "$REGISTRY" "${{ gitea.repository }}" >> "$GITHUB_OUTPUT" - - if: ${{ steps.plano.outputs.reuse != 'true' }} - uses: docker/setup-buildx-action@v4 - - if: ${{ steps.plano.outputs.reuse != 'true' }} uses: docker/login-action@v4 with: @@ -89,16 +86,12 @@ jobs: username: ${{ gitea.actor }} password: ${{ secrets.REGISTRY_TOKEN }} + # `docker build` simples, no daemon persistente do runner: as camadas e os + # cache mounts do Dockerfile (npm e compilação do Next) sobrevivem entre + # execuções. Um buildx criaria um BuildKit novo, e vazio, a cada job. - name: Build if: ${{ steps.plano.outputs.reuse != 'true' }} - uses: docker/build-push-action@v7 - with: - context: . - platforms: linux/arm64 - load: true - tags: espdocs:ci - cache-from: type=registry,ref=${{ steps.plano.outputs.image }}:buildcache - cache-to: type=registry,ref=${{ steps.plano.outputs.image }}:buildcache,mode=max + run: docker build -t espdocs:ci . - name: Trivy na imagem if: ${{ steps.plano.outputs.reuse != 'true' }} diff --git a/Dockerfile b/Dockerfile index 23d7a5e..458ca17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,14 +6,16 @@ WORKDIR /app # O Puppeteer só é usado em scripts locais (slides, capturas): não baixa o Chrome. ENV PUPPETEER_SKIP_DOWNLOAD=true COPY package.json package-lock.json ./ -RUN npm ci +# Cache do npm no daemon: dependências já baixadas não vão à rede de novo. +RUN --mount=type=cache,target=/root/.npm npm ci FROM node:22-alpine AS build WORKDIR /app ENV NEXT_TELEMETRY_DISABLED=1 NEXT_OUTPUT=standalone COPY --from=deps /app/node_modules ./node_modules COPY . . -RUN npm run build +# Cache de compilação do Next: só as páginas que mudaram são recompiladas. +RUN --mount=type=cache,target=/app/.next/cache npm run build FROM node:22-alpine WORKDIR /app