File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ COPY --chmod=444 package.json pnpm-lock.yaml ./
1111RUN pnpm install --ignore-scripts
1212
1313COPY --chmod=444 .env next.config.ts postcss.config.js tailwind.config.js tsconfig.json ./
14- COPY public public
15- COPY src src
14+ COPY --chmod=555 public public
15+ COPY --chmod=555 src src
1616
1717# Next.js collects completely anonymous telemetry data about general usage.
1818# Learn more here: https://nextjs.org/telemetry
@@ -30,13 +30,15 @@ ENV NEXT_TELEMETRY_DISABLED=1
3030
3131RUN addgroup --system --gid 1001 nodejs
3232RUN adduser --system --uid 1001 nextjs
33-
34- COPY --from=builder /app/public public
33+ # Copying files with root as owner, so that executing user cannot change the container i.e immutable and reproducible
34+ COPY --from=builder --chown=root:root --chmod=555 /app/public public
3535
3636# Automatically leverage output traces to reduce image size
3737# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
38- COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone .
39- COPY --from=builder --chown=nextjs:nodejs /app/.next/static .next/static
38+ COPY --from=builder --chown=root:root --chmod=555 /app/.next/standalone .
39+ # Create (if not there ) cache directory and assign ownership to nextjs user with write permission, so that cahce can be stored
40+ RUN mkdir -p /app/.next/cache && chown -R nextjs:nodejs /app/.next/cache && chmod -R 755 /app/.next/cache
41+ COPY --from=builder --chown=root:root --chmod=555 /app/.next/static .next/static
4042
4143USER nextjs
4244
You can’t perform that action at this time.
0 commit comments