34 lines
672 B
Docker
34 lines
672 B
Docker
FROM node:18-alpine AS build
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files first for better layer caching
|
|
COPY package.json package-lock.json* ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy the rest of the application
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:18-alpine AS production
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy only the built assets and necessary files from the build stage
|
|
COPY --from=build /app/dist ./dist
|
|
COPY --from=build /app/package.json ./
|
|
|
|
|
|
# Expose the port Vite uses by default
|
|
EXPOSE 5173
|
|
|
|
# Use a static file server for production builds
|
|
RUN npm install -g serve
|
|
|
|
# Serve the built application
|
|
CMD ["serve", "-s", "dist", "-l", "5173"] |