fix: resolve Docker container startup error with entrypoint script
All checks were successful
build-website / build (push) Successful in 2m12s
All checks were successful
build-website / build (push) Successful in 2m12s
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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"]
|
||||
# Use the entrypoint script
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
9
docker-entrypoint.sh
Normal file
9
docker-entrypoint.sh
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user