chore(deploy): prepara imagem standalone para homeserver
Some checks failed
CI / static (push) Failing after 5s
CI / int (push) Failing after 4s
CI / build (push) Failing after 3s
CI / e2e (1) (push) Failing after 4s
CI / e2e (2) (push) Failing after 4s
CI / checks (push) Failing after 2s
CI / deploy (push) Has been skipped
CI / requeue (push) Failing after 4s
Some checks failed
CI / static (push) Failing after 5s
CI / int (push) Failing after 4s
CI / build (push) Failing after 3s
CI / e2e (1) (push) Failing after 4s
CI / e2e (2) (push) Failing after 4s
CI / checks (push) Failing after 2s
CI / deploy (push) Has been skipped
CI / requeue (push) Failing after 4s
This commit is contained in:
parent
e0d2372d3b
commit
21b3c00d96
3 changed files with 67 additions and 27 deletions
34
.dockerignore
Normal file
34
.dockerignore
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
.next
|
||||||
|
.next-*
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
|
||||||
|
.agents
|
||||||
|
.codex
|
||||||
|
.cursor
|
||||||
|
.husky
|
||||||
|
.impeccable
|
||||||
|
.opencode
|
||||||
|
.playwright-cli
|
||||||
|
.playwright-mcp
|
||||||
|
.vercel
|
||||||
|
.vscode
|
||||||
|
.zed
|
||||||
|
|
||||||
|
coverage
|
||||||
|
data
|
||||||
|
docs
|
||||||
|
media
|
||||||
|
output
|
||||||
|
playwright-report
|
||||||
|
private
|
||||||
|
test-results
|
||||||
|
|
||||||
|
/*.png
|
||||||
|
*.log
|
||||||
|
*.tsbuildinfo
|
||||||
59
Dockerfile
59
Dockerfile
|
|
@ -1,23 +1,25 @@
|
||||||
# To use this Dockerfile, you have to set `output: 'standalone'` in your next.config.mjs file.
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
# From https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
|
# From https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile
|
||||||
|
|
||||||
FROM node:22.17.0-alpine AS base
|
FROM node:24.19.0-alpine AS base
|
||||||
|
|
||||||
|
RUN apk add --no-cache libc6-compat && corepack enable
|
||||||
|
|
||||||
# Install dependencies only when needed
|
# Install dependencies only when needed
|
||||||
FROM base AS deps
|
FROM base AS deps
|
||||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
|
||||||
RUN apk add --no-cache libc6-compat
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies based on the preferred package manager
|
# Install the pinned package manager and dependency graph.
|
||||||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./
|
COPY package.json pnpm-lock.yaml ./
|
||||||
RUN \
|
RUN pnpm install --frozen-lockfile
|
||||||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
|
|
||||||
elif [ -f package-lock.json ]; then npm ci; \
|
|
||||||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
|
|
||||||
else echo "Lockfile not found." && exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# One-shot image used to apply committed Payload migrations before a release.
|
||||||
|
FROM base AS migrator
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
|
COPY . .
|
||||||
|
CMD ["pnpm", "migrate"]
|
||||||
|
|
||||||
# Rebuild the source code only when needed
|
# Rebuild the source code only when needed
|
||||||
FROM base AS builder
|
FROM base AS builder
|
||||||
|
|
@ -25,25 +27,24 @@ WORKDIR /app
|
||||||
COPY --from=deps /app/node_modules ./node_modules
|
COPY --from=deps /app/node_modules ./node_modules
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Next.js collects completely anonymous telemetry data about general usage.
|
ARG NEXT_PUBLIC_SITE_URL
|
||||||
# Learn more here: https://nextjs.org/telemetry
|
ENV NEXT_PUBLIC_SITE_URL=$NEXT_PUBLIC_SITE_URL
|
||||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
|
||||||
|
|
||||||
RUN \
|
# Static generation reads Payload data. BuildKit mounts keep credentials out of
|
||||||
if [ -f yarn.lock ]; then yarn run build; \
|
# layers and image history; migrations run separately through the migrator.
|
||||||
elif [ -f package-lock.json ]; then npm run build; \
|
RUN --mount=type=secret,id=database_url,env=DATABASE_URL \
|
||||||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
|
--mount=type=secret,id=payload_secret,env=PAYLOAD_SECRET \
|
||||||
else echo "Lockfile not found." && exit 1; \
|
NEXT_OUTPUT_STANDALONE=1 \
|
||||||
fi
|
NODE_OPTIONS="--no-deprecation --max-old-space-size=8000" \
|
||||||
|
pnpm exec next build
|
||||||
|
|
||||||
# Production image, copy all the files and run next
|
# Production image, copy all the files and run next
|
||||||
FROM base AS runner
|
FROM base AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NODE_ENV production
|
ENV NODE_ENV=production
|
||||||
# Uncomment the following line in case you want to disable telemetry during runtime.
|
ENV NEXT_TELEMETRY_DISABLED=1
|
||||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
|
||||||
|
|
||||||
RUN addgroup --system --gid 1001 nodejs
|
RUN addgroup --system --gid 1001 nodejs
|
||||||
RUN adduser --system --uid 1001 nextjs
|
RUN adduser --system --uid 1001 nextjs
|
||||||
|
|
@ -64,8 +65,12 @@ USER nextjs
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
ENV PORT 3000
|
ENV PORT=3000
|
||||||
|
ENV HOSTNAME=0.0.0.0
|
||||||
|
|
||||||
# server.js is created by next build from the standalone output
|
# server.js is created by next build from the standalone output
|
||||||
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
|
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
|
||||||
CMD HOSTNAME="0.0.0.0" node server.js
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||||
|
CMD node -e "fetch('http://127.0.0.1:3000/').then((response) => { if (!response.ok) process.exit(1) }).catch(() => process.exit(1))"
|
||||||
|
|
||||||
|
CMD ["node", "server.js"]
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ const allowedImageHost = process.env.NEXT_PUBLIC_SITE_URL || 'https://jorgesolla
|
||||||
|
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
distDir: process.env.NEXT_DIST_DIR || '.next',
|
distDir: process.env.NEXT_DIST_DIR || '.next',
|
||||||
|
...(process.env.NEXT_OUTPUT_STANDALONE === '1' ? { output: 'standalone' } : {}),
|
||||||
images: {
|
images: {
|
||||||
remotePatterns: [new URL(`${allowedImageHost}/**`)],
|
remotePatterns: [new URL(`${allowedImageHost}/**`)],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue