ci: keep npm and Next compile caches across image builds
CI / Lint e auditorias (push) Successful in 45s
CI / Trivy (dependências e segredos) (push) Successful in 8s
CI / Imagem Docker (linux/arm64) (push) Successful in 4m11s
Release / Plano (reaproveitar a imagem?) (push) Successful in 5s
Release / ci (push) Skipped
Release / Publica a imagem (linux/arm64) (push) Successful in 2m40s
Release / Cria a release no Gitea (push) Skipped
CI / Lint e auditorias (push) Successful in 45s
CI / Trivy (dependências e segredos) (push) Successful in 8s
CI / Imagem Docker (linux/arm64) (push) Successful in 4m11s
Release / Plano (reaproveitar a imagem?) (push) Successful in 5s
Release / ci (push) Skipped
Release / Publica a imagem (linux/arm64) (push) Successful in 2m40s
Release / Cria a release no Gitea (push) Skipped
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ad130a334
commit
f6e10a293a
2 files changed
+8
-13
No files matched your search
+4
-11
@@ -79,9 +79,6 @@ jobs:
|
|||||||
- id: plano
|
- id: plano
|
||||||
run: scripts/plano-imagem.sh "$REGISTRY" "${{ gitea.repository }}" >> "$GITHUB_OUTPUT"
|
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' }}
|
- if: ${{ steps.plano.outputs.reuse != 'true' }}
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
@@ -89,16 +86,12 @@ jobs:
|
|||||||
username: ${{ gitea.actor }}
|
username: ${{ gitea.actor }}
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
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
|
- name: Build
|
||||||
if: ${{ steps.plano.outputs.reuse != 'true' }}
|
if: ${{ steps.plano.outputs.reuse != 'true' }}
|
||||||
uses: docker/build-push-action@v7
|
run: docker build -t espdocs:ci .
|
||||||
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
|
|
||||||
|
|
||||||
- name: Trivy na imagem
|
- name: Trivy na imagem
|
||||||
if: ${{ steps.plano.outputs.reuse != 'true' }}
|
if: ${{ steps.plano.outputs.reuse != 'true' }}
|
||||||
|
|||||||
+4
-2
@@ -6,14 +6,16 @@ WORKDIR /app
|
|||||||
# O Puppeteer só é usado em scripts locais (slides, capturas): não baixa o Chrome.
|
# O Puppeteer só é usado em scripts locais (slides, capturas): não baixa o Chrome.
|
||||||
ENV PUPPETEER_SKIP_DOWNLOAD=true
|
ENV PUPPETEER_SKIP_DOWNLOAD=true
|
||||||
COPY package.json package-lock.json ./
|
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
|
FROM node:22-alpine AS build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ENV NEXT_TELEMETRY_DISABLED=1 NEXT_OUTPUT=standalone
|
ENV NEXT_TELEMETRY_DISABLED=1 NEXT_OUTPUT=standalone
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
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
|
FROM node:22-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
Reference in new issue
Block a user