docker: image for the Oracle server, Trivy gate, and a release workflow
CI / Trivy (dependências e segredos) (push) Successful in 42s
CI / Lint, design e build (push) Canceled after 2m18s
CI / Imagem Docker (push) Canceled after 1m34s
CI / Trivy (dependências e segredos) (push) Successful in 36s
CI / Lint, design e build (push) Successful in 2m59s
CI / Imagem Docker (push) Successful in 2m59s
Release / ci (push) Successful in 3m37s
Release / Publica a imagem (linux/arm64) (push) Successful in 4m21s
CI / Trivy (dependências e segredos) (push) Successful in 42s
CI / Lint, design e build (push) Canceled after 2m18s
CI / Imagem Docker (push) Canceled after 1m34s
CI / Trivy (dependências e segredos) (push) Successful in 36s
CI / Lint, design e build (push) Successful in 2m59s
CI / Imagem Docker (push) Successful in 2m59s
Release / ci (push) Successful in 3m37s
Release / Publica a imagem (linux/arm64) (push) Successful in 4m21s
Next standalone build in three stages, non-root, healthchecked. next 15.5.28 (image-optimiser RCE) with postcss pinned past the copy bundled by next. release.yml publishes linux/arm64 to the Gitea registry. The book/ directory is a repository of its own and stays out of the build context. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aa636c83b1
commit
fd45d80287
7 files changed
+419
-323
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# Fora do contexto de build: dependências locais, saídas, outro repositório (book) e estado de ferramentas.
|
||||
node_modules
|
||||
.next
|
||||
dist
|
||||
build
|
||||
out
|
||||
coverage
|
||||
book
|
||||
.git
|
||||
.gitea
|
||||
.github
|
||||
.claude
|
||||
.superset
|
||||
.wolf
|
||||
.env*
|
||||
*.log
|
||||
*.tsbuildinfo
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
@@ -4,6 +4,8 @@ on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [main]
|
||||
# O release.yml roda esta mesma suíte antes de publicar a imagem.
|
||||
workflow_call:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -46,3 +48,46 @@ jobs:
|
||||
- run: npm run check
|
||||
|
||||
- run: npm run build
|
||||
|
||||
# Trivy roda pela imagem oficial: o trivy-action clona o repositório do Trivy
|
||||
# do mesmo servidor do workflow, que aqui é o Gitea, e não o GitHub.
|
||||
# O workspace do job é um volume que o daemon não enxerga, então os arquivos
|
||||
# entram no container com `docker cp` em vez de `-v`.
|
||||
seguranca:
|
||||
name: Trivy (dependências e segredos)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Repositório
|
||||
run: |
|
||||
cid=$(docker create --network host -v trivy-cache:/root/.cache/ -w /src aquasec/trivy:0.70.0 \
|
||||
fs --scanners vuln,secret,misconfig --severity HIGH,CRITICAL --exit-code 1 .)
|
||||
docker cp . "$cid:/src"
|
||||
docker start -a "$cid"
|
||||
status=$(docker inspect -f '{{.State.ExitCode}}' "$cid")
|
||||
docker rm "$cid" >/dev/null
|
||||
exit "$status"
|
||||
|
||||
imagem:
|
||||
name: Imagem Docker
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
# `docker build` simples: o cache de camadas fica no volume persistente do
|
||||
# daemon do runner, e o buildx criaria um BuildKit novo a cada job.
|
||||
- name: Build
|
||||
run: docker build -t espdocs:ci .
|
||||
- name: Trivy na imagem
|
||||
run: |
|
||||
docker run --rm --network host -v trivy-cache:/root/.cache/ -e DOCKER_HOST=tcp://127.0.0.1:2375 aquasec/trivy:0.70.0 \
|
||||
image --severity HIGH,CRITICAL --exit-code 1 espdocs:ci
|
||||
- name: A imagem sobe e responde
|
||||
run: |
|
||||
docker run -d --name espdocs-ci --network host -e PORT=3999 espdocs:ci
|
||||
for i in $(seq 1 30); do
|
||||
curl -fsS http://127.0.0.1:3999/ >/dev/null && ok=1 && break
|
||||
sleep 2
|
||||
done
|
||||
docker logs espdocs-ci | tail -5
|
||||
docker rm -f espdocs-ci >/dev/null
|
||||
test "${ok:-0}" = 1
|
||||
@@ -0,0 +1,67 @@
|
||||
name: Release
|
||||
|
||||
# Publica a imagem no registro de containers do Gitea depois de um merge em main,
|
||||
# e de novo com tag semver quando uma tag v* é enviada. O servidor só faz pull.
|
||||
# Precisa do secret de usuário REGISTRY_TOKEN (token do Gitea com write:package).
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: release
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
REGISTRY: git.lucasrguerra.dev.br
|
||||
|
||||
jobs:
|
||||
# Nada é publicado sem a suíte completa passar antes.
|
||||
ci:
|
||||
uses: ./.gitea/workflows/ci.yml
|
||||
|
||||
publicar:
|
||||
name: Publica a imagem (linux/arm64)
|
||||
needs: ci
|
||||
# O único runner é arm64 e o servidor de destino (Oracle) também, então a
|
||||
# imagem é construída nativamente, sem emulação.
|
||||
runs-on: ubuntu-24.04-arm
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- id: nome
|
||||
run: |
|
||||
repo='${{ gitea.repository }}'
|
||||
echo "image=${{ env.REGISTRY }}/${repo,,}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: Autentica no registro
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
- name: Metadados
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6
|
||||
with:
|
||||
images: ${{ steps.nome.outputs.image }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=raw,value=latest
|
||||
type=sha,format=long
|
||||
|
||||
- name: Build e push
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=registry,ref=${{ steps.nome.outputs.image }}:buildcache
|
||||
cache-to: type=registry,ref=${{ steps.nome.outputs.image }}:buildcache,mode=max
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
# ESPDocs: build do Next.js em três estágios; a imagem final leva só o servidor
|
||||
# "standalone" (sem node_modules inteiro nem código-fonte).
|
||||
|
||||
FROM node:22-alpine AS deps
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 PORT=3000 HOSTNAME=0.0.0.0
|
||||
# O servidor roda com `node server.js`: npm, corepack e yarn da base só ficariam
|
||||
# como superfície (e como achados de scanner) dentro da imagem.
|
||||
RUN apk upgrade --no-cache \
|
||||
&& rm -rf /usr/local/lib/node_modules/npm /usr/local/lib/node_modules/corepack \
|
||||
/usr/local/bin/npm /usr/local/bin/npx /usr/local/bin/corepack \
|
||||
/opt/yarn-* /usr/local/bin/yarn /usr/local/bin/yarnpkg
|
||||
COPY --from=build --chown=node:node /app/public ./public
|
||||
COPY --from=build --chown=node:node /app/.next/standalone ./
|
||||
COPY --from=build --chown=node:node /app/.next/static ./.next/static
|
||||
USER node
|
||||
EXPOSE 3000
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD node -e "fetch('http://127.0.0.1:'+process.env.PORT+'/').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
|
||||
CMD ["node", "server.js"]
|
||||
@@ -1,5 +1,8 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
// A imagem Docker liga isto (NEXT_OUTPUT=standalone) para empacotar só o que
|
||||
// o servidor usa. Fora dela o build continua igual: `next start`/pm2.
|
||||
output: process.env.NEXT_OUTPUT === "standalone" ? "standalone" : undefined,
|
||||
experimental: {
|
||||
optimizePackageImports: [
|
||||
"lucide-react",
|
||||
|
||||
Generated
+245
-322
File diff suppressed because it is too large.
Load diff
+6
-1
@@ -16,7 +16,7 @@
|
||||
"dependencies": {
|
||||
"googleapis": "^165.0.0",
|
||||
"lucide-react": "^1.16.0",
|
||||
"next": "^15.5.9",
|
||||
"next": "^15.5.28",
|
||||
"next-themes": "^0.4.6",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0"
|
||||
@@ -28,5 +28,10 @@
|
||||
"eslint-config-next": "15.5.6",
|
||||
"puppeteer": "^25.8.0",
|
||||
"tailwindcss": "^4"
|
||||
},
|
||||
"overrides": {
|
||||
"next": {
|
||||
"postcss": "^8.5.25"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user