first version which seems to run
This commit is contained in:
61
Dockerfile
Normal file
61
Dockerfile
Normal file
@@ -0,0 +1,61 @@
|
||||
FROM node:22-alpine AS base
|
||||
|
||||
RUN corepack enable
|
||||
RUN apk add --no-cache libc6-compat
|
||||
|
||||
# --- Dependencies stage ---
|
||||
FROM base AS deps
|
||||
WORKDIR /app
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# --- Builder stage ---
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
ENV DOCKER_BUILD=true
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV TINA_PUBLIC_IS_LOCAL=false
|
||||
ENV NODE_OPTIONS="--dns-result-order=ipv4first"
|
||||
|
||||
RUN npx tinacms build && npx next build
|
||||
RUN npx pagefind --site .next --output-path .next/static/pagefind
|
||||
|
||||
# --- Runner stage ---
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV TINA_PUBLIC_IS_LOCAL=false
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
# Copy standalone output
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/content ./content
|
||||
COPY --from=builder /app/tina ./tina
|
||||
|
||||
# Copy the startup indexing script
|
||||
COPY --from=builder /app/scripts/index-database.mjs ./scripts/index-database.mjs
|
||||
|
||||
# Pagefind static search index
|
||||
COPY --from=builder /app/.next/static/pagefind ./.next/static/pagefind
|
||||
|
||||
# Create cache directory with correct permissions
|
||||
RUN mkdir -p .next/cache && chown -R nextjs:nodejs .next/cache
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
# Entrypoint: index content into Redis, then start Next.js
|
||||
CMD ["sh", "-c", "node scripts/index-database.mjs && node server.js"]
|
||||
Reference in New Issue
Block a user