Files
website/Dockerfile
Matt bbf9c0d436
All checks were successful
build-website / build (push) Successful in 2m12s
fix: resolve Docker container startup error with entrypoint script
- 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>
2025-09-26 20:02:50 +02:00

43 lines
912 B
Docker

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm ci
# Copy all files
COPY . .
# Build Next.js app
RUN npm run build
# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV HOSTNAME="0.0.0.0"
ENV PORT=3000
# Create a non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
# Copy standalone build output with proper ownership
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 the entrypoint script
ENTRYPOINT ["/docker-entrypoint.sh"]