Dockerfile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. # Install openssl and inotify-tools for dynamic SSL reloading
  16. RUN apk add --no-cache openssl inotify-tools
  17. COPY --from=build-stage /app/dist /usr/share/nginx/html
  18. COPY nginx.conf /etc/nginx/conf.d/default.conf
  19. COPY entrypoint.sh /entrypoint.sh
  20. RUN chmod +x /entrypoint.sh
  21. EXPOSE 80 443
  22. ENTRYPOINT ["/entrypoint.sh"]
  23. # Development Stage
  24. FROM node:18-alpine as dev-stage
  25. WORKDIR /app
  26. COPY package*.json ./
  27. # Use NPM Mirror
  28. RUN npm config set registry https://registry.npmmirror.com
  29. RUN npm install
  30. COPY . .
  31. # We will run 'vite' in development mode (or 'vite preview' for prod-like serving,
  32. # but Uvicorn user usually implies a simpler dev-like setup or just Python preference).
  33. # Since user asked "Why not use Uvicorn for frontend", strictly speaking Uvicorn is Python server.
  34. # Frontend (Vue) is JS. We cannot run Vue with Uvicorn directly.
  35. # BUT, we can use Vite's preview or dev server.
  36. # Expose Vite's default port
  37. EXPOSE 5173
  38. # Host 0.0.0.0 is needed for Docker
  39. CMD ["npm", "run", "dev", "--", "--host", "0.0.0.0"]