Add PDF reports, file uploads, admin auth, and comprehensive tests

Features:
- PDF service for generating task reports with ReportLab-style formatting
- Storage service for file uploads (local and S3-compatible)
- Admin authentication middleware with JWT support
- Admin user model and repository

Infrastructure:
- Updated Docker configuration for admin panel builds
- Email service enhancements for task notifications
- Updated router with admin and file upload routes
- Environment configuration updates

Tests:
- Unit tests for handlers (auth, residence, task)
- Unit tests for models (user, residence, task)
- Unit tests for repositories (user, residence, task)
- Unit tests for services (residence, task)
- Integration test setup
- Test utilities for mocking database and services

Database:
- Admin user seed data
- Updated test data seeds

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-11-27 23:36:20 -06:00
parent 2817deee3c
commit 469f21a833
50 changed files with 6795 additions and 582 deletions

View File

@@ -1,4 +1,21 @@
# Build stage
# Admin panel build stage
FROM node:20-alpine AS admin-builder
WORKDIR /app
# Copy admin panel files
COPY admin/package*.json ./
# Install dependencies
RUN npm ci
# Copy source
COPY admin/ .
# Build (standalone mode)
RUN npm run build
# Go build stage
FROM golang:1.23-alpine AS builder
# Install build dependencies
@@ -22,11 +39,8 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/api
# Build the worker binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/worker ./cmd/worker
# Build the admin binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/admin ./cmd/admin
# Final stage - Production API (default target for Dokku)
FROM alpine:3.19
# Base runtime stage for Go services
FROM alpine:3.19 AS go-base
# Install runtime dependencies
RUN apk add --no-cache ca-certificates tzdata curl
@@ -40,7 +54,6 @@ WORKDIR /app
# Copy all binaries from builder
COPY --from=builder /app/api /app/api
COPY --from=builder /app/worker /app/worker
COPY --from=builder /app/admin /app/admin
# Copy templates directory
COPY --from=builder /app/templates /app/templates
@@ -55,12 +68,42 @@ RUN mkdir -p /app/uploads && chown -R app:app /app
# Switch to non-root user
USER app
# Expose port (Dokku will set PORT env var to 5000)
EXPOSE 5000
# API stage
FROM go-base AS api
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:${PORT:-8000}/api/health/ || exit 1
CMD ["/app/api"]
# Health check using curl (more reliable)
# Worker stage
FROM go-base AS worker
CMD ["/app/worker"]
# Admin panel runtime stage
FROM node:20-alpine AS admin
WORKDIR /app
# Create non-root user
RUN addgroup -g 1001 nodejs && adduser -u 1001 -G nodejs -s /bin/sh -D nextjs
# Copy standalone build
COPY --from=admin-builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=admin-builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=admin-builder --chown=nextjs:nodejs /app/public ./public
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
# Default production stage (for Dokku - runs API)
FROM go-base AS production
EXPOSE 5000
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD curl -f http://localhost:${PORT:-5000}/api/health/ || exit 1
# Run the API (default command)
CMD ["/app/api"]