mitlist/fe/Dockerfile.prod
mohamad d05200b623
All checks were successful
Deploy to Production, build images and push to Gitea Registry / build_and_push (pull_request) Successful in 38s
refactor: Update frontend components and Dockerfile for production
- Changed the build command in Dockerfile from `npm run build` to `npm run build-only` for optimized production builds.
- Simplified service worker initialization by removing conditional precaching logic.
- Enhanced styling and structure in `VListItem.vue` and `ListDetailPage.vue` for better readability and consistency with Valerie UI components.
- Improved focus handling in item addition and editing processes for better user experience.
- Cleaned up unused CSS classes and ensured consistent usage of Valerie UI components across the application.
2025-06-01 14:59:30 +02:00

69 lines
1.6 KiB
Docker

# Multi-stage build for production
FROM node:23-alpine AS base
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production && npm cache clean --force
# Development stage
FROM base AS development
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
CMD ["npm", "run", "dev"]
# Build stage
FROM base AS build
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install all dependencies (including devDependencies)
RUN npm ci
# Copy source code
COPY . .
# Set environment variables for build
ENV NODE_ENV=production
# Build the application
RUN npm run build-only
# Production stage
FROM node:slim AS production
# Install serve globally
RUN npm install -g serve
# Set working directory
WORKDIR /app
# Copy built assets from build stage
COPY --from=build /app/dist .
# Create a default static.json for serve to handle SPA routing
RUN echo '{ \n "rewrites": [ \n { "source": "**", "destination": "/index.html" } \n ] \n}' > static.json
# Create a script to inject environment variables at runtime
RUN echo '#!/bin/sh\n\
echo "window.ENV = { \
VITE_API_URL: \"$VITE_API_URL\", \
VITE_SENTRY_DSN: \"$VITE_SENTRY_DSN\", \
VITE_ROUTER_MODE: \"$VITE_ROUTER_MODE\" \
}" > /app/env-config.js\n\
serve -s . -l 3000' > /app/start.sh && chmod +x /app/start.sh
# Expose port 3000 (serve default)
EXPOSE 3000
# Health check (optional, depends on serve capabilities or custom health endpoint)
# HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
# CMD curl -f http://localhost:3000/ || exit 1
# Start serve with environment variable injection
CMD ["/app/start.sh"]