| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- FROM node:18-alpine as build-stage
- WORKDIR /app
- COPY package*.json ./
- # Use NPM Mirror
- RUN npm config set registry https://registry.npmmirror.com
- RUN npm install
- COPY . .
- # Build args
- ARG VITE_API_BASE_URL=/api/v1
- ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
- # Build for production
- RUN npm run build
- # Production Stage with Nginx
- FROM nginx:stable-alpine as production-stage
- COPY --from=build-stage /app/dist /usr/share/nginx/html
- COPY nginx.conf /etc/nginx/conf.d/default.conf
- EXPOSE 80
- CMD ["nginx", "-g", "daemon off;"]
- # Development Stage
- FROM node:18-alpine as dev-stage
- WORKDIR /app
- COPY package*.json ./
- # Use NPM Mirror
- RUN npm config set registry https://registry.npmmirror.com
- RUN npm install
- COPY . .
- # We will run 'vite' in development mode (or 'vite preview' for prod-like serving,
- # but Uvicorn user usually implies a simpler dev-like setup or just Python preference).
- # Since user asked "Why not use Uvicorn for frontend", strictly speaking Uvicorn is Python server.
- # Frontend (Vue) is JS. We cannot run Vue with Uvicorn directly.
- # BUT, we can use Vite's preview or dev server.
- # Expose Vite's default port
- EXPOSE 5173
- # Host 0.0.0.0 is needed for Docker
- CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
|