diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3b7bb0b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +.gitignore +.idea +node_modules +.next +out +.env* +.vercel +*.log +.next +npm-debug.log* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2db5241 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3ee129d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +# Секреты — только из .env (см. .env.local.example) +services: + web: + build: . + ports: + - "3000:3000" + env_file: + - .env.local + restart: unless-stopped diff --git a/next.config.mjs b/next.config.mjs index 5e5b4f4..4dce508 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -17,6 +17,7 @@ const securityHeaders = [ const nextConfig = { reactStrictMode: true, poweredByHeader: false, + output: "standalone", async headers() { return [ {