diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af9c341 --- /dev/null +++ b/.gitignore @@ -0,0 +1,46 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.idea +/package-lock.json +/.pnp +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* +pnpm-lock.yaml + +# env files (can opt-in for committing if needed) +.env + +# vs extentions +.vscode/ +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e436d4d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +# --------------------- +# Base (PNPM + Node) +# --------------------- +FROM docker.arvancloud.ir/node:22-alpine AS base +RUN apk add --no-cache libc6-compat +WORKDIR /app +RUN npm install -g pnpm@10.8.0 + +# --------------------- +# Dependencies +# --------------------- +FROM base AS deps +WORKDIR /app +COPY package.json pnpm-lock.yaml ./ +RUN pnpm install --frozen-lockfile + +# --------------------- +# Builder +# --------------------- +FROM base AS builder +WORKDIR /app + +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NEXT_TELEMETRY_DISABLED=1 +ENV NEXT_PRIVATE_STANDALONE=true + +RUN pnpm build + +# --------------------- +# Runner +# --------------------- +FROM docker.arvancloud.ir/node:22-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV PORT=3000 + +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs +EXPOSE 3000 + +CMD ["node", "server.js"] diff --git a/README.Docker.md b/README.Docker.md new file mode 100644 index 0000000..e69de29 diff --git a/app/globals.css b/app/globals.css deleted file mode 100644 index 3d552a6..0000000 --- a/app/globals.css +++ /dev/null @@ -1,2 +0,0 @@ -@import "tailwindcss"; - diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..035c945 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +services: + witelflix-front: + image: witelflix:${VERSION} + container_name: witelflix + # build: #just if we have internet uncomment + # context: . + # dockerfile: Dockerfile + ports: + - "3000:3000" + env_file: + - .env + restart: unless-stopped + # volumes: + # - .:/app # کل پروژه mount شده به /app در کانتینر + # - /app/node_modules # node_modules داخل کانتینر بماند تا با host override نشود + # - /app/.next # next داخل کانتینر بماند تا با host override نشود diff --git a/src/app/globals.css b/src/app/globals.css new file mode 100644 index 0000000..a461c50 --- /dev/null +++ b/src/app/globals.css @@ -0,0 +1 @@ +@import "tailwindcss"; \ No newline at end of file diff --git a/app/layout.tsx b/src/app/layout.tsx similarity index 100% rename from app/layout.tsx rename to src/app/layout.tsx diff --git a/app/page.tsx b/src/app/page.tsx similarity index 100% rename from app/page.tsx rename to src/app/page.tsx diff --git a/tailwind.config.ts b/tailwind.config.ts index 0ae0410..7a01b00 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -1,7 +1,7 @@ import type { Config } from "tailwindcss"; const config: Config = { - content: ["./app/**/*.{ts,tsx}"], + content: ["./src/app/**/*.{ts,tsx}"], theme: { extend: {}, }, diff --git a/tsconfig.json b/tsconfig.json index 7f7913c..0c811ca 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,6 +30,10 @@ ".next/types/**/*.ts", ".next/dev/types/**/*.ts" ], + "paths": { + "@/*": ["./src/*"], + "&/*": ["./public/*"] + }, "exclude": [ "node_modules" ]