This commit is contained in:
alirehmani
2024-05-06 17:35:56 +05:00
parent a969ab41ed
commit 43459be8c5
7 changed files with 70 additions and 29 deletions

View File

@@ -0,0 +1,32 @@
# Stage 1: Build the Vite application
FROM node:20 AS builder
# Set the working directory in the container
WORKDIR /app
# Copy the package.json and package-lock.json first to leverage Docker's cache
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy the application code
COPY . .
# Build the Vite application
RUN npm run build
# Stage 2: Create the runtime image
FROM nginx:alpine
# Copy the built Vite application from the builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy a custom Nginx configuration file (if you need one)
# COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 80
EXPOSE 80
# Start the Nginx server
CMD ["nginx", "-g", "daemon off;"]