From ed743d2977200614b573da85c1fab75b00039c00 Mon Sep 17 00:00:00 2001 From: RedrockJS Date: Wed, 28 May 2025 09:46:28 +0300 Subject: [PATCH] fix: dockerfile --- Dockerfile | 19 +++++++++++++------ next.config.ts | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index e61708c..2e4f8c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,16 +20,20 @@ RUN npm run build FROM node:22-alpine AS runner WORKDIR /app +ENV NODE_ENV=production \ + NEXT_TELEMETRY_DISABLED=1 + # Включаем node пользователя RUN addgroup -g 1001 -S nodejs RUN adduser -S nextjs -u 1001 +# Set the correct permission for prerender cache +RUN mkdir .next +RUN chown nextjs:nodejs .next + # Копируем необходимые файлы из стадии builder -COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next -COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules -COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json -COPY --from=builder --chown=nextjs:nodejs /app/public ./public -COPY --from=builder --chown=nextjs:nodejs /app/next.config.js ./next.config.js +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static # Переключаем на пользователя nextjs USER nextjs @@ -38,4 +42,7 @@ USER nextjs EXPOSE 3000 # Запускаем приложение -CMD ["npm", "start"] +ENV PORT 3000 +ENV HOSTNAME "0.0.0.0" + +CMD ["node", "server.js"] diff --git a/next.config.ts b/next.config.ts index e9ffa30..55238ac 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,6 +2,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ + output: 'standalone', }; export default nextConfig; -- 2.49.1