mirror of
https://github.com/civitai/civitai.git
synced 2026-09-20 22:08:18 +08:00
Optimize Docker build caching and slim image
- Add pnpm store cache mount so package reuse survives layer invalidation - Copy only prisma schema files (not migrations/programmability/seed) into deps - Remove prisma and scripts from runner stage (no longer running migrations in container) - Expand .dockerignore to exclude docs, tests, .claude, .github, .vscode (~30MB less context) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -7,4 +7,13 @@ nginx
|
||||
.git
|
||||
.gitignore
|
||||
.next
|
||||
.dockerignore
|
||||
.dockerignore
|
||||
docs
|
||||
tests
|
||||
.claude
|
||||
.github
|
||||
.vscode
|
||||
playwright.config.ts
|
||||
prisma/migrations
|
||||
prisma/programmability
|
||||
prisma/seed.ts
|
||||
+9
-11
@@ -7,18 +7,18 @@ WORKDIR /app
|
||||
# Enable corepack for pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@10.28.1 --activate
|
||||
|
||||
# Install Prisma Client - remove if not using Prisma
|
||||
# Copy Prisma schemas for client generation (postinstall runs prisma generate)
|
||||
COPY prisma/schema.full.prisma prisma/schema.prisma ./prisma/
|
||||
|
||||
COPY prisma ./prisma
|
||||
|
||||
# Install dependencies
|
||||
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# copy ./scripts directory to /app/scripts to run prisma enum generator
|
||||
# Install dependencies — lockfile and scripts rarely change, so they go first.
|
||||
# package.json changes on every version bump but pnpm only needs it for the
|
||||
# workspace root name; the store cache mount lets pnpm reuse downloaded packages
|
||||
# even when this layer is invalidated.
|
||||
COPY pnpm-lock.yaml package.json ./
|
||||
COPY scripts ./scripts
|
||||
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
##### BUILDER
|
||||
|
||||
@@ -56,8 +56,6 @@ RUN adduser --system --uid 1001 nextjs
|
||||
COPY --from=builder /app/next.config.mjs ./
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
COPY --from=builder /app/scripts ./scripts
|
||||
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
Reference in New Issue
Block a user