build error fixes
This commit is contained in:
21
DockerFile
21
DockerFile
@ -1,17 +1,21 @@
|
|||||||
# Stage 1: Build
|
# Stage 1: Build
|
||||||
FROM node:18-alpine AS builder
|
FROM node:18-alpine AS builder
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package files and install dependencies
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm install --production
|
RUN npm install --production
|
||||||
|
|
||||||
|
# Copy the rest of the app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build-time environment variable
|
# Pass build-time environment variable
|
||||||
ARG NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
|
ARG NEXT_PUBLIC_API_URL
|
||||||
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||||
|
|
||||||
|
# Build the Next.js app
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Run
|
# Stage 2: Run
|
||||||
@ -19,18 +23,23 @@ FROM node:18-alpine AS runner
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=builder /app/package.json ./
|
# Copy built app from builder
|
||||||
COPY --from=builder /app/package-lock.json ./
|
|
||||||
COPY --from=builder /app/.next ./.next
|
COPY --from=builder /app/.next ./.next
|
||||||
COPY --from=builder /app/public ./public
|
COPY --from=builder /app/public ./public
|
||||||
|
COPY --from=builder /app/package.json ./package.json
|
||||||
|
COPY --from=builder /app/package-lock.json ./package-lock.json
|
||||||
COPY --from=builder /app/next.config.js ./next.config.js
|
COPY --from=builder /app/next.config.js ./next.config.js
|
||||||
|
|
||||||
|
# Install only production dependencies
|
||||||
RUN npm install --production
|
RUN npm install --production
|
||||||
|
|
||||||
|
# Expose port
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Runtime environment variables
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
ENV NEXT_PUBLIC_API_URL=https://cmcbackend.rootxwire.com
|
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
||||||
ENV HOST=0.0.0.0
|
ENV HOST=0.0.0.0
|
||||||
|
|
||||||
|
# Start the app
|
||||||
CMD ["npm", "start"]
|
CMD ["npm", "start"]
|
||||||
|
|||||||
@ -2,14 +2,13 @@ version: "3.9"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
nextjs:
|
nextjs:
|
||||||
build:
|
build: .
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
NEXT_PUBLIC_API_URL: https://cmcbackend.rootxwire.com
|
|
||||||
container_name: cmc_nextjs_pro
|
container_name: cmc_nextjs_pro
|
||||||
ports:
|
ports:
|
||||||
- "9012:3000"
|
- "9012:3000"
|
||||||
environment:
|
env_file:
|
||||||
NODE_ENV: production
|
- .env # <-- tell Docker to use the .env file
|
||||||
NEXT_PUBLIC_API_URL: https://cmcbackend.rootxwire.com
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
- /app/node_modules
|
||||||
|
|||||||
Reference in New Issue
Block a user