diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d5abb4c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +.next +.git +.env +npm-debug.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..90aa24e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Build stage +FROM node:20-alpine AS builder + +WORKDIR /app + +COPY package*.json ./ +RUN npm ci + +COPY . . +RUN npm run build + +# Production stage +FROM node:20-alpine + +WORKDIR /app +ENV NODE_ENV=production + +COPY --from=builder /app/package*.json ./ +RUN npm ci --omit=dev + +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public + +EXPOSE 3000 +CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c6887ae --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + nextjs: + build: . + container_name: my-nextjs-app + restart: unless-stopped + ports: + - "3000:3000" + env_file: + - .env \ No newline at end of file