diff --git a/Dockerfile b/Dockerfile index c694612..93acc96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ FROM image-build AS dependencies WORKDIR /app -ARG NPM_REGISTRY=https://package-mirror.liara.ir/repository/npm/ +ARG NPM_REGISTRY=https://registry.npmjs.org/ ENV NEXT_TELEMETRY_DISABLED=1 \ PKG_CONFIG_PATH=/opt/vips/lib/pkgconfig \ LD_LIBRARY_PATH=/opt/vips/lib \ @@ -40,21 +40,21 @@ RUN --mount=type=cache,id=portfolio-npm-node22,target=/root/.npm,sharing=locked RUN if [ "$(uname -m)" = x86_64 ]; then export CFLAGS='-O2 -march=x86-64 -mtune=generic' CXXFLAGS='-O2 -march=x86-64 -mtune=generic'; fi \ && npm explore sharp -- npm run build -COPY scripts/check-image-runtime.mjs ./scripts/check-image-runtime.mjs -RUN node scripts/check-image-runtime.mjs --require-source -FROM dependencies AS verification +FROM dependencies AS build -COPY . . -RUN npm run lint -RUN npm run typecheck +# Only application inputs invalidate compilation. Tests and docs stay outside. +COPY next.config.mjs tsconfig.json next-env.d.ts ./ +COPY src ./src +COPY public ./public +COPY migrations ./migrations +COPY scripts/maintenance.ts scripts/build-maintenance.mjs scripts/prepare-standalone.mjs ./scripts/ RUN --mount=type=cache,id=portfolio-next-node22,target=/app/.next/cache,sharing=locked \ npm run build -RUN npm test # Carry the exact shared-library dependency closure from the working build stage. # Development packages can provide libraries that are absent from image-runtime. -FROM verification AS native-runtime-libraries +FROM dependencies AS native-runtime-libraries RUN mkdir -p /runtime-libs \ && (ldd /app/node_modules/sharp/src/build/Release/*.node /opt/vips/lib/libvips*.so* 2>/dev/null || true) \ | awk '/=> \// { print $3 } /^[[:space:]]*\// { print $1 }' \ @@ -77,15 +77,11 @@ ENV NODE_ENV=production \ RUN addgroup --system --gid 1001 nodejs \ && adduser --system --uid 1001 nextjs -COPY --from=verification --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=verification --chown=nextjs:nodejs /app/.next/static ./.next/static -COPY --from=verification --chown=nextjs:nodejs /app/public ./public +COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=image-build /opt/vips/lib /opt/vips/lib # Preserve the package and its native dependency closure beyond Next's tracing. COPY --from=dependencies --chown=nextjs:nodejs /app/node_modules/sharp/ ./node_modules/sharp/ COPY --from=native-runtime-libraries /runtime-libs/ / -COPY scripts/check-image-runtime.mjs ./scripts/check-image-runtime.mjs -RUN node scripts/check-image-runtime.mjs --require-source RUN mkdir -p .next/cache /data && chown -R nextjs:nodejs .next/cache /data USER nextjs diff --git a/SELF_HOSTING.md b/SELF_HOSTING.md index 803ad29..a8b0273 100644 --- a/SELF_HOSTING.md +++ b/SELF_HOSTING.md @@ -67,7 +67,10 @@ Use a single application instance and local storage. SQLite is not intended for multiple replicas or a network filesystem. Startup applies committed migrations. The image includes `maintenance.mjs`, so maintenance needs no npm installation. Baseline CPU support for image processing is retained; native compilation is -cached separately and can make the first build slower. +cached separately and can make the first build slower. UI edits reuse dependency +and native-library layers. Docker builds only the application, including Next.js +TypeScript validation, and packages it; lint, audits, tests, and image probes do +not run in the production build. Postbuild packages assets once. ## Persistent files and configuration