Dockerfile 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. FROM node:18-alpine as build-stage
  2. WORKDIR /app
  3. COPY package*.json ./
  4. # Use NPM Mirror
  5. RUN npm config set registry https://registry.npmmirror.com
  6. RUN npm install
  7. COPY . .
  8. # Build args
  9. ARG VITE_API_BASE_URL=/api/v1
  10. ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
  11. # Build for production
  12. RUN npm run build
  13. # Production Stage with Nginx
  14. FROM nginx:stable-alpine as production-stage
  15. COPY --from=build-stage /app/dist /usr/share/nginx/html
  16. COPY nginx.conf /etc/nginx/conf.d/default.conf
  17. EXPOSE 80
  18. CMD ["nginx", "-g", "daemon off;"]
  19. # Development Stage
  20. FROM node:18-alpine as dev-stage
  21. WORKDIR /app
  22. COPY package*.json ./
  23. # Use NPM Mirror
  24. RUN npm config set registry https://registry.npmmirror.com
  25. RUN npm install
  26. COPY . .
  27. # We will run 'vite' in development mode (or 'vite preview' for prod-like serving,
  28. # but Uvicorn user usually implies a simpler dev-like setup or just Python preference).
  29. # Since user asked "Why not use Uvicorn for frontend", strictly speaking Uvicorn is Python server.
  30. # Frontend (Vue) is JS. We cannot run Vue with Uvicorn directly.
  31. # BUT, we can use Vite's preview or dev server.
  32. # Expose Vite's default port
  33. EXPOSE 5173
  34. # Host 0.0.0.0 is needed for Docker
  35. CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]