From 86b4a01bf3c8a0107bed3e39f5c2e3bcbc1e74d6 Mon Sep 17 00:00:00 2001 From: mukeshs Date: Thu, 9 Oct 2025 23:03:51 +0530 Subject: [PATCH] build error fixes --- DockerFile | 49 ++++++++++++---------------------------------- docker-compose.yml | 3 ++- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/DockerFile b/DockerFile index 1f62296..2802a98 100644 --- a/DockerFile +++ b/DockerFile @@ -1,48 +1,23 @@ -# Use Node.js LTS Alpine for smaller image -FROM node:20-alpine AS base +FROM node:18-alpine -# Set working directory WORKDIR /app -# Install dependencies only when needed -FROM base AS deps -COPY package.json package-lock.json* ./ -RUN npm ci --only=production +# Copy package files and install dependencies +COPY package.json package-lock.json ./ +RUN npm install -# Build the app -FROM base AS builder -COPY package.json package-lock.json* ./ -RUN npm ci +# Copy the rest of the code COPY . . -ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com -ENV NEXT_TELEMETRY_DISABLED=1 - +# Build Next.js RUN npm run build -# Production image -FROM base AS runner -ENV NODE_ENV=production -ENV NEXT_TELEMETRY_DISABLED=1 - -# Create non-root user -RUN addgroup --system --gid 1001 nodejs && \ - adduser --system --uid 1001 nextjs - -WORKDIR /app - -# Copy all necessary files -COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json -COPY --from=builder --chown=nextjs:nodejs /app/package-lock.json ./package-lock.json -COPY --from=builder --chown=nextjs:nodejs /app/next.config.js ./next.config.js -COPY --from=builder --chown=nextjs:nodejs /app/public ./public -COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next -COPY --from=deps --chown=nextjs:nodejs /app/node_modules ./node_modules - -USER nextjs - EXPOSE 3000 -ENV PORT=3000 +# Make sure Next.js binds to all interfaces +ENV HOST=0.0.0.0 -CMD ["npm", "start"] \ No newline at end of file +# Optionally, set the API URL here if you want +ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com + +CMD ["npm", "start"] diff --git a/docker-compose.yml b/docker-compose.yml index 5908d80..a95bfbf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,8 @@ services: - "9012:3000" environment: - NODE_ENV=production + - NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com restart: unless-stopped volumes: - .:/app - - /app/node_modules + - /app/node_modules \ No newline at end of file