diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0d5826 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +# Stage 1: Build the Next.js application +FROM node:20-alpine AS builder + +# Set working directory +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm ci + +# Copy the rest of the application code +COPY . . + +# Build the Next.js application +RUN npm run build + +# Stage 2: Create the production image +FROM node:20-alpine AS runner + +WORKDIR /app + +# Set environment to production +ENV NODE_ENV production + +# Copy necessary files from the builder stage +COPY --from=builder /app/next.config.js ./ +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package.json ./package.json + +# Expose the port the app will run on +EXPOSE 3000 + +# Start the application +CMD ["npm", "start"] diff --git a/README.md b/README.md index 301bde3..12b1c90 100755 --- a/README.md +++ b/README.md @@ -28,6 +28,19 @@ Start the development server: `npm run dev` Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. +### Running with Docker + +1. Build the Docker image: + ``` + docker build -t nextjs-tailwind-comingsoon . + ``` + +2. Run the Docker container: + ``` + docker run -p 3000:3000 nextjs-tailwind-comingsoon + ``` + +3. 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.