Refactor building containerizing application #48

Merged
shaerpour merged 2 commits from refactor/website into main 2025-01-20 09:55:02 -05:00
2 changed files with 31 additions and 4 deletions

View file

@ -1,11 +1,37 @@
FROM node:20.10.0 FROM node:20.10.0-alpine AS base
FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci --legacy-peer-deps
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
RUN npm install --force
RUN npm run build RUN npm run build
EXPOSE 6080 FROM base AS runner
WORKDIR /app
CMD ["npm", "run", "start"] ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]

View file

@ -5,6 +5,7 @@ const nextConfig = {
defaultLocale: 'fa' defaultLocale: 'fa'
}, },
reactStrictMode: true, reactStrictMode: true,
output: "standalone"
}; };
export default nextConfig; export default nextConfig;