vue-color-avatar/Dockerfile
LeoKu 1bfa640506 refactor: update Dockerfile and package management to use pnpm
- Transitioned from Yarn to pnpm for package management, updating package.json scripts accordingly.
- Enhanced Dockerfile for better build efficiency by separating dependency installation and application build steps.
- Updated Docker commands in README files to reflect changes in port mapping and image tagging.
- Added healthcheck to the Dockerfile for improved container reliability.
2025-01-23 16:57:01 +08:00

35 lines
720 B
Docker

# Build stage
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app
# Install dependencies first (for better caching)
COPY package.json pnpm-lock.yaml ./
RUN corepack enable pnpm && pnpm install --frozen-lockfile
# Copy source code
COPY . .
# Build the application
RUN pnpm build
# Production stage
FROM nginx:alpine
# Copy custom nginx config if needed
# COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Add healthcheck
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --quiet --tries=1 --spider http://localhost:80/ || exit 1
# Expose port
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]