Compare commits
2 Commits
master
...
2f1c7d9c9c
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f1c7d9c9c | |||
| 2f9f05d638 |
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.git
|
||||
.next
|
||||
node_modules
|
||||
39
Dockerfile
39
Dockerfile
@@ -1,39 +1,32 @@
|
||||
# Base image
|
||||
FROM node:22-alpine AS builder
|
||||
# Stage 1: Build
|
||||
FROM node:18-slim 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 dependencies first to cache better
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm install
|
||||
|
||||
# Copy the rest of the application
|
||||
# Copy all source code
|
||||
COPY . .
|
||||
|
||||
# Build the app
|
||||
# Build the Next.js app
|
||||
RUN npm run build
|
||||
|
||||
# Production image
|
||||
FROM node:22-alpine AS runner
|
||||
|
||||
# Stage 2: Run production image
|
||||
FROM node:18-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only necessary files
|
||||
COPY --from=builder /app/package.json ./
|
||||
COPY --from=builder /app/package.json /app/package-lock.json ./
|
||||
RUN npm install --omit=dev
|
||||
|
||||
COPY --from=builder /app/.next .next
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/public public
|
||||
COPY --from=builder /app/next.config.ts ./
|
||||
COPY --from=builder /app/src src
|
||||
|
||||
# Set environment variables (optional)
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3000
|
||||
|
||||
# Start the application
|
||||
CMD ["npm", "start"]
|
||||
CMD ["npx", "next", "start"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: '3.9'
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
app:
|
||||
@@ -7,21 +7,6 @@ services:
|
||||
dockerfile: Dockerfile
|
||||
container_name: cosmos-crm
|
||||
ports:
|
||||
- '3000:3000'
|
||||
- "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:
|
||||
- JWT_SECRET=8f2e9c4a7b1d6e3f8a5b2c9e6f1a4d7b8e3f6a9c2d5e8b1f4a7c0e3d6f9b2a5c8
|
||||
|
||||
@@ -3,14 +3,14 @@ import { db } from "@/database/database";
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
// Initialize database
|
||||
await db.read();
|
||||
|
||||
// Parse dependant ID from params
|
||||
const dependantId = parseInt(params.id);
|
||||
const dependantId = parseInt((await params).id);
|
||||
|
||||
if (isNaN(dependantId)) {
|
||||
return NextResponse.json(
|
||||
@@ -61,14 +61,14 @@ export async function GET(
|
||||
|
||||
export async function PUT(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
// Initialize database
|
||||
await db.read();
|
||||
|
||||
// Parse dependant ID from params
|
||||
const dependantId = parseInt(params.id);
|
||||
const dependantId = parseInt((await params).id);
|
||||
|
||||
if (isNaN(dependantId)) {
|
||||
return NextResponse.json(
|
||||
@@ -141,14 +141,14 @@ export async function PUT(
|
||||
|
||||
export async function DELETE(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
// Initialize database
|
||||
await db.read();
|
||||
|
||||
// Parse dependant ID from params
|
||||
const dependantId = parseInt(params.id);
|
||||
const dependantId = parseInt((await params).id);
|
||||
|
||||
if (isNaN(dependantId)) {
|
||||
return NextResponse.json(
|
||||
|
||||
Reference in New Issue
Block a user