BREAKING: Full rewrite from static HTML to production-grade stack. Features: - React 18 + Vite + Tailwind CSS (mobile-first) - Express + Prisma + PostgreSQL backend - JWT authentication with role-based access - Weekly Mon-Sun timesheets with auto-save - Multiple homeowner entries per day - Submit → Approve/Reject workflow - Server-side PDF generation - SMTP email integration - Admin panel with reporting & filters - Dark mode (system-aware) - Docker Compose one-command deploy - Non-root containers, Helmet, bcrypt, Zod validation
57 lines
1.9 KiB
Docker
57 lines
1.9 KiB
Docker
# ───────────────────────────────────────────────────
|
|
# Coastal Timesheet — Frontend Dockerfile
|
|
# Build: Node 22 Alpine → Serve: Nginx Alpine
|
|
# ───────────────────────────────────────────────────
|
|
|
|
# ── Stage 1: Install dependencies ──────────────────
|
|
FROM node:22-alpine AS deps
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files (frontend lives in the frontend/ directory)
|
|
COPY frontend/package.json frontend/package-lock.json* ./
|
|
|
|
# Install all dependencies (including devDependencies for build)
|
|
RUN npm ci 2>/dev/null || npm install
|
|
|
|
# ── Stage 2: Build ────────────────────────────────
|
|
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy dependencies
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
# Copy frontend source
|
|
COPY frontend/ ./
|
|
|
|
# Set API URL for production build
|
|
ARG VITE_API_URL=/api
|
|
ENV VITE_API_URL=${VITE_API_URL}
|
|
|
|
# Build the React app
|
|
RUN npm run build
|
|
|
|
# ── Stage 3: Serve with Nginx ─────────────────────
|
|
FROM nginx:1.27-alpine AS runner
|
|
|
|
# Remove default nginx config and static files
|
|
RUN rm -rf /etc/nginx/conf.d/default.conf /usr/share/nginx/html/*
|
|
|
|
# Copy built frontend assets
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# The nginx config is mounted via docker-compose volume
|
|
# but we include a fallback in case it's run standalone
|
|
COPY docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Expose ports
|
|
EXPOSE 80 443
|
|
|
|
# Nginx runs as non-root by default in alpine image
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:80/ || exit 1
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|