From b7ddedb2e8260c9166b92c682abb30e32be1bff3 Mon Sep 17 00:00:00 2001 From: Sovereignty Date: Fri, 13 Jun 2025 18:36:57 +0200 Subject: [PATCH] feat: Add Dockerfile for production deployment --- Dockerfile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a3e53a2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +# ---- Stage 1: Build the React App ---- +# Use an official Node.js image as the base for building +FROM node:20-alpine AS build + +# Set the working directory inside the container +WORKDIR /app + +# Copy package.json and package-lock.json to leverage Docker layer caching +COPY package*.json ./ + +# Install all dependencies +RUN npm install + +# Copy the rest of the application source code +COPY . . + +# Build the application for production +# This runs "vite build" and creates the /app/dist folder +RUN npm run build + +# ---- Stage 2: Serve the App in a Production Environment ---- +# Use a smaller, secure Node.js image for the final container +FROM node:20-alpine + +WORKDIR /app + +# We only need package.json to install the 'serve' package +COPY package*.json ./ + +# Install ONLY production dependencies (in this case, 'serve') +RUN npm install --omit=dev + +# Copy the built static files from the 'build' stage +COPY --from=build /app/dist ./dist + +# Expose the port that 'serve' will run on +EXPOSE 3000 + +# The command to start the web server +# This runs "serve -s dist" +CMD [ "npm", "start" ] \ No newline at end of file