From bbf9c0d436a84c5a8b5ea7f34a864f99df301895 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 26 Sep 2025 20:02:50 +0200 Subject: [PATCH] fix: resolve Docker container startup error with entrypoint script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created docker-entrypoint.sh script to properly start Next.js server - Script explicitly changes to /app directory and runs node server.js - Updated Dockerfile to copy and use the entrypoint script - This fixes the "Cannot find module '/server.js'" error - Makes deployment more robust against container orchestration overrides The container now has a proper entrypoint that Portainer expects and correctly starts the Next.js standalone server. 🤖 Generated with Claude Code Co-Authored-By: Claude --- Dockerfile | 9 ++++++--- docker-entrypoint.sh | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 docker-entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 733930f..8c71da4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,10 +31,13 @@ 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/public ./public +# Copy and set up entrypoint script +COPY --chown=nextjs:nodejs docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh + USER nextjs EXPOSE 3000 -# Use ENTRYPOINT and CMD for better container control -ENTRYPOINT ["node"] -CMD ["server.js"] \ No newline at end of file +# Use the entrypoint script +ENTRYPOINT ["/docker-entrypoint.sh"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..ec21c60 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +# Change to app directory +cd /app + +# Start the Next.js server +echo "Starting Next.js server..." +exec node server.js \ No newline at end of file