From 8ee7bc896dd87a54bc3da26d333bd74bb28dcbfc Mon Sep 17 00:00:00 2001 From: Bivekich Date: Wed, 6 Aug 2025 12:51:55 +0300 Subject: [PATCH] fix env --- Dockerfile | 21 +++++++++++++++++++-- docker-compose.yml | 20 ++++++++++++++++++-- next.config.js | 1 + stack.env | 29 +++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 stack.env diff --git a/Dockerfile b/Dockerfile index 6ca1e3d..5e93989 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,14 @@ WORKDIR /app # Copy package files COPY package*.json ./ -# Install dependencies -RUN npm install +# Install all dependencies (including dev dependencies for build) +RUN npm ci + +# Copy prisma schema +COPY prisma ./prisma/ + +# Generate Prisma client +RUN npx prisma generate # Copy project files COPY . . @@ -23,11 +29,22 @@ WORKDIR /app ENV NODE_ENV=production +# Create non-root user +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + # Copy necessary files from builder COPY --from=builder /app/next.config.js ./ COPY --from=builder /app/public ./public COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma +COPY --from=builder /app/prisma ./prisma + +# Set correct permissions +RUN chown -R nextjs:nodejs /app + +USER nextjs EXPOSE 3000 diff --git a/docker-compose.yml b/docker-compose.yml index 2753703..1a86f68 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,23 @@ services: context: . dockerfile: Dockerfile ports: - - "3006:3000" + - "${PORT:-3006}:3000" environment: - - NODE_ENV=production + - NODE_ENV=${NODE_ENV:-production} + - DATABASE_URL=${DATABASE_URL} + - NEXTAUTH_SECRET=${NEXTAUTH_SECRET} + - S3_ENDPOINT=${S3_ENDPOINT} + - S3_REGION=${S3_REGION} + - S3_ACCESS_KEY_ID=${S3_ACCESS_KEY_ID} + - S3_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY} + - S3_BUCKET_NAME=${S3_BUCKET_NAME} + - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} + - TELEGRAM_CHAT_ID=${TELEGRAM_CHAT_ID} + - NEXTAUTH_URL=${NEXTAUTH_URL} restart: unless-stopped + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health", "||", "exit", "1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s diff --git a/next.config.js b/next.config.js index e5e1190..c452344 100644 --- a/next.config.js +++ b/next.config.js @@ -23,6 +23,7 @@ const nextConfig = { }, ], }, + output: 'standalone', }; module.exports = nextConfig; diff --git a/stack.env b/stack.env new file mode 100644 index 0000000..9773a0c --- /dev/null +++ b/stack.env @@ -0,0 +1,29 @@ +# ==================================================================== +# STACK ENVIRONMENT VARIABLES FOR DEPLOYMENT +# ==================================================================== + +# Port configuration +PORT=3006 + +# Environment +NODE_ENV=production + +# Database configuration +DATABASE_URL=postgresql://ckeproekt:y0i_-yCfeL@85.234.110.60:5432/ckeproekt + +# Authentication & Security +NEXTAUTH_SECRET=15455c6e0f1e5aa95945e23a591acbd0baf11c1589e08c36d95afefa496e6a64510ee98dbf9a4afade12bec2cb3a4d1e0e9b238048c8cef927c9ce568ea4a0a7 + +# S3 Storage Configuration +S3_ENDPOINT=https://s3.twcstorage.ru +S3_REGION=ru-1 +S3_ACCESS_KEY_ID=I6XD2OR7YO2ZN6L6Z629 +S3_SECRET_ACCESS_KEY=9xCOoafisG0aB9lJNvdLO1UuK73fBvMcpHMdijrJ +S3_BUCKET_NAME=617774af-ckeproekt + +# Telegram Bot Configuration +TELEGRAM_BOT_TOKEN=7802786776:AAGQGYf2BxuBFmZOhRcLTX52KnUEYifTKZY +TELEGRAM_CHAT_ID=-1002321880357 + +# Next.js URL (update with your domain) +NEXTAUTH_URL=https://ckeproekt.ru \ No newline at end of file