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: