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: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
# Optionally, set the API URL here if you want
ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
CMD ["npm", "start"]

View File

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