From fa1c1a9f45b54c83220e3b92772a99ca4527c561 Mon Sep 17 00:00:00 2001 From: Lukas Reichart Date: Sun, 29 Dec 2024 13:11:43 +0100 Subject: [PATCH] Add Dockerfile --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cabb745 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Step 1: Set the base image to Node.js +FROM node:18-alpine AS build + +# Step 2: Set the working directory inside the container +WORKDIR /app + +# Step 3: Copy the package.json and package-lock.json (or yarn.lock) for dependency installation +COPY package.json package-lock.json ./ + +# Step 4: Install dependencies +RUN npm install + +# Step 5: Copy the rest of the project files into the container +COPY . . + +# Step 6: Build the Next.js app +RUN npm run build + +# Step 7: Create the final image (production stage) +FROM node:18-alpine + +# Set the working directory inside the container for production +WORKDIR /app + +# Copy the necessary files from the build stage +COPY --from=build /app ./ + +# Step 8: Install production dependencies only (optional) +RUN npm install --production + +# Step 9: Expose the default Next.js port +EXPOSE 3000 + +# Step 10: Set the command to run the Next.js app +CMD ["npm", "start"]