diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a3f9f45 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# Stage 1: Build the application +FROM node:18 AS builder + +# Set the working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package.json package-lock.json* ./ + +# Install dependencies +RUN npm install --legacy-peer-deps +RUN npm ci +# Copy the rest of the application files +COPY . . + +# Build the application +RUN npm run build + +# Stage 2: Serve the application +FROM builder AS runner + +# Set the working directory +WORKDIR /app +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 + +# Expose the application port +EXPOSE 3100 + +# Start the application on port 3100 +ENV PORT=3100 +CMD ["npm", "run", "dev"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..55343af --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + nextjs: + container_name: nextjs-app + build: + context: . + dockerfile: Dockerfile + ports: + - "3100:3100" + environment: + - PORT=3100 + volumes: + - .:/app # Mount the current directory to /app in the container \ No newline at end of file