fix: dockerfile

This commit is contained in:
2025-05-28 09:46:28 +03:00
parent 8cc177b9a7
commit ed743d2977
2 changed files with 14 additions and 6 deletions

View File

@@ -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"]

View File

@@ -2,6 +2,7 @@ import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
output: 'standalone',
};
export default nextConfig;