From 89bf2fe70cb491cfbc7c5c2a6fa799c355e2d433 Mon Sep 17 00:00:00 2001 From: Mehdi Mehrmanesh Date: Sat, 11 Oct 2025 17:28:26 +0330 Subject: [PATCH] update deploy.yaml --- .github/workflows/deploy.yaml | 6 ++- Dockerfile | 86 ++++++++++++++++++++++++++++++----- 2 files changed, 79 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index c812f64..4c4016f 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -11,8 +11,10 @@ jobs: env: DANAK_SERVER: "https://captain.dev.danakcorp.com" - APP_TOKEN: 111ac60c637716478be8ab8b888fd20baba808a10b0fc0c18bf788766883ec9e - APP_NAME: e-commerce-front + APP_TOKEN: 230cbe758f711c2b12099fce48ef8d4f2212ac6dc89cb300e92a9b8a45133669 + APP_NAME: shop + # APP_TOKEN: 111ac60c637716478be8ab8b888fd20baba808a10b0fc0c18bf788766883ec9e + # APP_NAME: e-commerce-front GITHUB_TOKEN: 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 steps: diff --git a/Dockerfile b/Dockerfile index bbc5d5f..5f8a133 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,53 @@ +# ------------------------ +# Base image +# ------------------------ FROM node:22-alpine AS base -RUN apk add --no-cache tzdata && \ - cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && \ - echo "Asia/Tehran" > /etc/timezone +RUN apk add --no-cache tzdata \ + && cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime \ + && echo "Asia/Tehran" > /etc/timezone WORKDIR /app +# ------------------------ +# Dependencies stage +# ------------------------ FROM base AS deps + RUN apk add --no-cache libc6-compat git + COPY package*.json ./ -RUN npm ci --only=production --ignore-scripts +RUN npm ci + +# ------------------------ +# Builder stage +# ------------------------ FROM base AS builder -WORKDIR /build -COPY --from=deps /app/node_modules ./node_modules -COPY . . -RUN npm run build && npm ci --only=production --ignore-scripts +WORKDIR /build + +COPY --from=deps /app/node_modules ./node_modules + +COPY . . + +# Build پروژه Next.js +RUN npm run build + +# ------------------------ +# Runner stage (production) +# ------------------------ FROM base AS runner + WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" RUN addgroup -S appgroup && adduser -S appuser -G appgroup + RUN mkdir .next && chown appuser:appgroup .next COPY --from=builder --chown=appuser:appgroup /build/.next/standalone ./ @@ -34,7 +58,47 @@ COPY --from=builder --chown=appuser:appgroup /build/package.json ./package.json USER appuser EXPOSE 3000 -ENV PORT=3000 -ENV HOSTNAME="0.0.0.0" -CMD ["node", "server.js"] \ No newline at end of file +CMD ["node", "server.js"] + + +# FROM node:22-alpine AS base + +# RUN apk add --no-cache tzdata && \ +# cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && \ +# echo "Asia/Tehran" > /etc/timezone + +# WORKDIR /app + +# FROM base AS deps +# RUN apk add --no-cache libc6-compat git +# COPY package*.json ./ +# RUN npm ci --only=production --ignore-scripts + +# FROM base AS builder +# WORKDIR /build +# COPY --from=deps /app/node_modules ./node_modules +# COPY . . +# RUN npm run build && npm ci --only=production --ignore-scripts + +# FROM base AS runner +# WORKDIR /app + +# ENV NODE_ENV=production +# ENV NEXT_TELEMETRY_DISABLED=1 + +# RUN addgroup -S appgroup && adduser -S appuser -G appgroup +# RUN mkdir .next && chown appuser:appgroup .next + +# COPY --from=builder --chown=appuser:appgroup /build/.next/standalone ./ +# COPY --from=builder --chown=appuser:appgroup /build/.next/static ./.next/static +# COPY --from=builder --chown=appuser:appgroup /build/public ./public +# COPY --from=builder --chown=appuser:appgroup /build/package.json ./package.json + +# USER appuser + +# EXPOSE 3000 +# ENV PORT=3000 +# ENV HOSTNAME="0.0.0.0" + +# CMD ["node", "server.js"] \ No newline at end of file