Files
newz-qwen-27b/frontend/Dockerfile
Daniel Samson ffe19272b3 feat: add React + TypeScript frontend with Vite, routing, tests and Docker setup
M3 frontend infrastructure for the newzy news application:

- Vite + React 18 + TypeScript project (Node >=18) in frontend/
- React Router v6: BrowserRouter in App.tsx, routes for /, /articles,
  /articles/:id and /categories, Link/NavLink-based navigation
- lucide-react icons (Home, FileText, Settings, Search, ...) in the
  responsive Header (desktop + mobile menu) and article components
- Reusable components: ArticleCard, AuthorAvatar, CategoryBadge (CVA),
  Layout shell with backend API status indicator in the footer
- Typed API client (fetch wrapper, ApiError, endpoint helpers) with
  types matching the backend models; sample-data fallback until the
  backend article endpoints exist
- Tailwind CSS global/component styles, cn() helper (clsx + tailwind-merge)
- Unit tests: Vitest + React Testing Library (23 tests, 100% statement
  coverage on components)
- E2E tests: Playwright (9 tests) covering page shell, feed rendering,
  client-side navigation, article route and API interactions
- ESLint (react + react-hooks + typescript) configured and passing
- Multi-stage Dockerfile (Vite build -> Nginx) with SPA fallback and an
  /api/ proxy to the backend service; docker-compose frontend service on
  port 3000 in both frontend/ and the root docker-compose.yml
- README with setup, API documentation, testing and Docker instructions
2026-10-30 14:10:29 +00:00

33 lines
877 B
Docker

# syntax=docker/dockerfile:1
# --- Stage 1: build the production bundle ---------------------------------
FROM node:20-alpine AS build
WORKDIR /app
# Install dependencies first to leverage Docker layer caching.
COPY package.json package-lock.json ./
RUN npm ci
# Copy application source and build.
COPY . .
ARG VITE_API_BASE_URL=/api/v1
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
RUN npm run build
# --- Stage 2: serve static files with Nginx --------------------------------
FROM nginx:1.27-alpine
# SPA + API proxy configuration (proxies /api/ to the backend service).
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Production bundle from the build stage.
COPY --from=build /app/dist /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD wget -qO- http://localhost/ >/dev/null 2>&1 || exit 1
CMD ["nginx", "-g", "daemon off;"]