build error fixes

This commit is contained in:
2025-10-09 23:03:51 +05:30
parent 653ba8e551
commit 86b4a01bf3
2 changed files with 14 additions and 38 deletions

View File

@ -1,48 +1,23 @@
# Use Node.js LTS Alpine for smaller image FROM node:18-alpine
FROM node:20-alpine AS base
# Set working directory
WORKDIR /app WORKDIR /app
# Install dependencies only when needed # Copy package files and install dependencies
FROM base AS deps COPY package.json package-lock.json ./
COPY package.json package-lock.json* ./ RUN npm install
RUN npm ci --only=production
# Build the app # Copy the rest of the code
FROM base AS builder
COPY package.json package-lock.json* ./
RUN npm ci
COPY . . COPY . .
ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com # Build Next.js
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build 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 EXPOSE 3000
ENV PORT=3000 # Make sure Next.js binds to all interfaces
ENV HOST=0.0.0.0
# Optionally, set the API URL here if you want
ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
CMD ["npm", "start"] CMD ["npm", "start"]

View File

@ -8,6 +8,7 @@ services:
- "9012:3000" - "9012:3000"
environment: environment:
- NODE_ENV=production - NODE_ENV=production
- NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- .:/app - .:/app