vite/Dockerfile
Rama main · réplica de lectura del repositorio original.
# syntax=docker/dockerfile:1
# Dependencies stage
FROM node:20-alpine AS deps
WORKDIR /app
# Install dependencies based on the package manager
COPY package.json package-lock.json* ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --verbose
# Development stage
FROM node:20-alpine AS development
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
# Copy package files (rarely change)
COPY package.json package-lock.json* ./
# Copy ALL config files in one layer (rarely change together)
COPY vite.config.ts tsconfig*.json eslint.config.js openapi-ts.config.js components.json index.html ./
# Copy source code (changes frequently - put last)
COPY src ./src
COPY public ./public
# Expose port and start dev server
EXPOSE 3000
CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0", "--port", "3000"]
# Builder stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy dependencies from deps stage
COPY --from=deps /app/node_modules ./node_modules
# Copy package files (rarely change)
COPY package.json package-lock.json* ./
# Copy ALL config files in one layer (rarely change together)
COPY vite.config.ts tsconfig*.json eslint.config.js openapi-ts.config.js components.json index.html ./
# Copy environment file (generated by CI or copied locally)
COPY .env.production ./
# Copy source code (changes frequently - put last)
COPY src ./src
COPY public ./public
# Build the application
RUN npm run build
# Production stage
FROM nginx:alpine AS production
WORKDIR /app
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]