feat: enhance Dockerfile with health check and secure permissions; update next.config.ts formatting

This commit is contained in:
an14051
2026-05-13 00:30:19 +02:00
parent af0d8b3458
commit 9c96e742fa
2 changed files with 26 additions and 9 deletions
+25 -7
View File
@@ -24,21 +24,39 @@ WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
# Dedicated non-root user # Suppress debconf warnings in Docker
RUN apt-get update && apt-get install -y --no-install-recommends adduser && rm -rf /var/lib/apt/lists/* && \ ENV DEBIAN_FRONTEND=noninteractive
addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Next.js standalone output # Dedicated non-root user
RUN apt-get update && \
apt-get install -y --no-install-recommends adduser && \
rm -rf /var/lib/apt/lists/* && \
addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Create writable data directory with proper permissions
RUN mkdir -p /app/data/uploads && \
chown -R nextjs:nodejs /app/data && \
chmod 750 /app/data && \
chmod 700 /app/data/uploads
# Copy only production artifacts from builder (no source code, no node_modules)
COPY --from=builder /app/public ./public COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Writable data directory for file uploads # Secure filesystem permissions
RUN mkdir -p /app/data/uploads && chown -R nextjs:nodejs /app/data RUN chmod 755 /app && \
chmod 755 /app/.next && \
chmod 755 /app/public
# Switch to non-root user
USER nextjs USER nextjs
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD bun --eval "import('http').then(h => h.request('http://localhost:3000/', res => process.exit(res.statusCode === 200 ? 0 : 1)).end())" || exit 1
EXPOSE 3000 EXPOSE 3000
ENV PORT=3000 ENV PORT=3000
+1 -2
View File
@@ -14,8 +14,7 @@ const securityHeaders = [
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
output: "standalone", output: "standalone",
serverExternalPackages: ["@libsql/client"], serverExternalPackages: ["@libsql/client"], productionBrowserSourceMaps: false, experimental: {
experimental: {
serverActions: { serverActions: {
bodySizeLimit: "500mb", bodySizeLimit: "500mb",
}, },