From 1d505b8639fad2135f7304c2672af30cc62d277a Mon Sep 17 00:00:00 2001 From: tungdtsothink Date: Thu, 10 Jul 2025 10:21:52 +0700 Subject: [PATCH 1/2] Add docker --- Dockerfile | 39 +++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 27 +++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..766f441 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,39 @@ +# Base image +FROM node:22-alpine AS builder + +ARG NODE_ENV=production +ARG MONGODB_URI +ARG MONGODB_DB + +# Create app directory +WORKDIR /app + +# Install dependencies +COPY package.json package-lock.json* ./ +RUN npm ci + +# Copy the rest of the application +COPY . . + +# Build the app +RUN npm run build + +# Production image +FROM node:22-alpine AS runner + +WORKDIR /app + +# Copy only necessary files +COPY --from=builder /app/package.json ./ +COPY --from=builder /app/.next .next +COPY --from=builder /app/public ./public +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/next.config.ts ./ + +# Set environment variables (optional) + +# Expose port +EXPOSE 3000 + +# Start the application +CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..6a9572d --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,27 @@ +version: '3.9' + +services: + app: + build: + context: . + dockerfile: Dockerfile + container_name: cosmos-crm + ports: + - '3000:3000' + environment: + - NODE_ENV=development + - MONGODB_URI=mongodb://mongo:27017 + - MONGODB_DB=cosmos-crm + depends_on: + - mongo + + mongo: + image: mongo:7 + container_name: mongo + ports: + - '27017:27017' + volumes: + - mongo-data:/data/db + +volumes: + mongo-data: From 78cc39d86911d332735a50e4374cbc844005b559 Mon Sep 17 00:00:00 2001 From: tungdtsothink Date: Thu, 10 Jul 2025 10:42:30 +0700 Subject: [PATCH 2/2] Update README.md file --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 568447e..b8406c5 100644 --- a/README.md +++ b/README.md @@ -6,18 +6,27 @@ Environment requirements - NodeJS version 22 or latest - npm version 10.9.2 or latest -First, run the development server: +Environment variable +- Make .env.local file in `root` folder +```env + JWT_SECRET=your secret key +``` + +Install package +```bash + npm install +``` + +Run the development server: ```bash -npm run dev + npm run dev ``` Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. - ## Application features - Login - username: `admin`