Added Dockerfile

This commit is contained in:
Ram Prashanth 2025-08-19 16:26:51 +08:00
parent 6ad81a04ad
commit ca87accc03
2 changed files with 50 additions and 9 deletions

41
Dockerfile Normal file
View File

@ -0,0 +1,41 @@
# Multi-stage build for Next.js application
FROM node:18-alpine AS base
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
# Build the application
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
# Production image - run Next.js server
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
# Copy only necessary files
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=deps /app/node_modules ./node_modules
COPY --from=builder /app/.next ./.next
RUN chown -R nextjs:nodejs /app
USER nextjs
ENV PORT=3000
EXPOSE ${PORT}
# Run Next.js with npm start
CMD ["npm", "start"]

View File

@ -1,13 +1,13 @@
/** @type {import('next').NextConfig} */
const basePath = process.env.BASE_PATH || ''
const basePath = process.env.BASE_PATH || "";
const nextConfig = {
output: 'export',
trailingSlash: true,
images: {
unoptimized: true
},
basePath
}
// output: "export",
trailingSlash: true,
images: {
unoptimized: true,
},
basePath,
};
module.exports = nextConfig
module.exports = nextConfig;