build error fixes
This commit is contained in:
27
DockerFile
27
DockerFile
@ -7,17 +7,23 @@ WORKDIR /app
|
||||
# Install dependencies only when needed
|
||||
FROM base AS deps
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm install --frozen-lockfile || npm install
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Build the app
|
||||
FROM base AS builder
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
|
||||
ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# Production image, copy only necessary files
|
||||
# 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 && \
|
||||
@ -25,13 +31,18 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy build output and node_modules
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next ./.next
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
# 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
|
||||
|
||||
CMD ["npm", "start"]
|
||||
Reference in New Issue
Block a user