build error fixes

This commit is contained in:
2025-10-09 23:12:48 +05:30
parent 86b4a01bf3
commit 83346d0031
3 changed files with 31 additions and 21 deletions

View File

@ -1,23 +1,36 @@
FROM node:18-alpine
# Stage 1: Build
FROM node:18-alpine AS builder
WORKDIR /app
# Copy package files and install dependencies
COPY package.json package-lock.json ./
RUN npm install
RUN npm install --production
# Copy the rest of the code
COPY . .
# Build Next.js
# Build-time environment variable
ARG NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
RUN npm run build
# Stage 2: Run
FROM node:18-alpine AS runner
WORKDIR /app
COPY --from=builder /app/package.json ./
COPY --from=builder /app/package-lock.json ./
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/next.config.js ./next.config.js
RUN npm install --production
EXPOSE 3000
# Make sure Next.js binds to all interfaces
ENV NODE_ENV=production
ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
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"]