Compare commits

1 Commits
Author SHA1 Message Date
prog1764 207ec7e56b docker: подготовка к запуску в контейнере (Next.js)
- Dockerfile: multi-stage (deps/build/runner), standalone-сборка, non-root user
- next.config.mjs: output: 'standalone'
- docker-compose.yml: порт 3000, env из .env.local
- .dockerignore: node_modules, .next, .env*, кэш
- проверено: npm run build прошёл, standalone артефакт на месте
2026-08-04 20:23:16 +04:00
4 changed files with 54 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
.git
.gitignore
.idea
node_modules
.next
out
.env*
.vercel
*.log
.next
npm-debug.log*
+33
View File
@@ -0,0 +1,33 @@
# ---- deps ----
FROM node:20-alpine AS deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --no-audit --no-fund
# ---- build ----
FROM node:20-alpine AS build
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# ---- runtime ----
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production \
NEXT_TELEMETRY_DISABLED=1 \
PORT=3000 \
HOSTNAME=0.0.0.0
RUN addgroup -S nodejs && adduser -S nextjs -G nodejs
COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=build --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=build --chown=nextjs:nodejs /app/public ./public
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]
+9
View File
@@ -0,0 +1,9 @@
# Секреты — только из .env (см. .env.local.example)
services:
web:
build: .
ports:
- "3000:3000"
env_file:
- .env.local
restart: unless-stopped
+1
View File
@@ -17,6 +17,7 @@ const securityHeaders = [
const nextConfig = {
reactStrictMode: true,
poweredByHeader: false,
output: "standalone",
async headers() {
return [
{