feat(docker): standalone output for slim frontend image (886MB → 219MB)
This commit is contained in:
parent
87802db0f4
commit
6279bd4f31
|
|
@ -32,19 +32,15 @@ ENV NEXT_PUBLIC_API_URL=auto
|
|||
ENV NEXT_PUBLIC_AUTH_MODE=${NEXT_PUBLIC_AUTH_MODE}
|
||||
|
||||
# Create non-root user before COPY so --chown can reference it.
|
||||
# Using COPY --chown avoids a slow recursive chown on overlay2 (docker/for-linux#388).
|
||||
RUN addgroup -S appgroup && adduser -S -G appgroup appuser \
|
||||
&& chown appuser:appgroup /app
|
||||
RUN addgroup -S appgroup && adduser -S -G appgroup appuser
|
||||
|
||||
COPY --from=builder --chown=appuser:appgroup /app/.next ./.next
|
||||
# `public/` is optional in Next.js apps; repo may not have it.
|
||||
# Avoid failing the build when the directory is absent.
|
||||
COPY --from=builder --chown=appuser:appgroup /app/package.json ./package.json
|
||||
COPY --from=builder --chown=appuser:appgroup /app/node_modules ./node_modules
|
||||
COPY --from=builder --chown=appuser:appgroup /app/next.config.ts ./next.config.ts
|
||||
# Copy standalone output from builder
|
||||
COPY --from=builder --chown=appuser:appgroup /app/.next/standalone ./
|
||||
COPY --from=builder --chown=appuser:appgroup /app/.next/static ./.next/static
|
||||
COPY --from=builder --chown=appuser:appgroup /app/public ./public
|
||||
|
||||
USER appuser
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npm", "run", "start"]
|
||||
CMD ["node", "server.js"]
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: "standalone",
|
||||
// In dev, Next may proxy requests based on the request origin/host.
|
||||
// Allow common local origins so `next dev --hostname 127.0.0.1` works
|
||||
// when users access via http://localhost:3000 or http://127.0.0.1:3000.
|
||||
|
|
|
|||
Loading…
Reference in New Issue