Files
brachnha-insight/Dockerfile
Max 90f807b31d Fix Docker build - Add PORT environment variable
- Add PORT=3000 to both Dockerfile and docker-compose.yml
- Ensure proper file ownership in standalone build
- Fix potential 404 routing issues

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-26 13:08:04 +07:00

50 lines
950 B
Docker

# Build stage
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app
# Copy package files
COPY package.json package-lock.json ./
# Install dependencies
RUN npm ci
# Copy all source files
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM node:20-alpine AS runner
# Set working directory
WORKDIR /app
# Set environment to production
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Create a non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy necessary files from builder
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Change ownership to nextjs user
RUN chown -R nextjs:nodejs /app
# Switch to nextjs user
USER nextjs
# Expose port 3000
EXPOSE 3000
# Start the application
CMD ["node", "server.js"]