tercul-frontend/Dockerfile
Damir Mukimov ea2ef8fa6d
Fix/typescript testing issues (#12)
* feat: Add missing shared schema types and fix TypeScript imports

- Add AuthorWithStats and AnnotationWithUser schemas with relations
- Add corresponding TypeScript type exports
- Update tsconfig.json with @shared/* path mapping
- Fix @shared/schema import issues across components
- Resolve major TypeScript compilation errors

Next: Fix remaining type mismatches and component prop issues

* fix: resolve major TypeScript errors and type mismatches

- Add AuthorWithStats and AnnotationWithUser schemas with proper relations
- Fix AnnotationSystem component type issues (string IDs, nested user objects)
- Update component props to match schema expectations
- Fix function parameter types for annotation operations
- Resolve null/undefined type assignments
- Add missing required properties (type, isOfficial) to annotations

Remaining issues: Test ES module configuration and some component prop type mismatches

* fix: resolve remaining TypeScript errors and improve type safety

- Fix tag-manager component to work with string IDs from schema
- Update author-stats component to use schema-based AuthorWithStats type
- Add missing utility functions (formatNumber, formatRating) to author utils
- Fix WorkCard test to use correct schema types with string IDs
- Resolve type mismatches in component props and form handling
- Update interface definitions to match schema requirements

Linting:  90%+ resolved, remaining minor issues
Testing: ⚠️ ES module configuration needs refinement

* fix: complete TypeScript fixes and testing refinements

- Fix remaining AnnotationSystem component type issues
- Update FilterSidebar to use string tag IDs
- Resolve all major TypeScript compilation errors
- Testing infrastructure fully functional with Jest + ES modules
- Linting errors reduced to minor unused variable warnings

All critical type safety and testing issues resolved!

* Fix annotation types and author utils

* Fix TypeScript and testing infrastructure issues

- Fix AnnotationSystem component types (string IDs, user objects, liked/likes properties)
- Add formatNumber and formatRating utilities for author components
- Update FilterSidebar to use correct tag ID types (string vs number)
- Fix EnhancedReadingView translation and work ID type mismatches
- Resolve Playwright dependency issues in testing setup
- Update Jest configuration for ES module compatibility
- Fix import paths and type conflicts across components

All unit tests now pass and major TypeScript compilation errors resolved.

* Fix Vite build configuration for CI

- Set root to 'client' directory to find index.html
- Configure path aliases (@/* and @shared/*) for proper module resolution
- Set build output directory to '../dist' to place files in frontend root

Resolves CI build failure: 'Could not resolve entry module index.html'

* Fix Docker build for Yarn v4

- Replace deprecated 'yarn install --immutable --production' with 'yarn workspaces focus --production'
- This resolves the YN0050 error in CI Docker builds

Yarn v4 deprecated the --production flag on install command.
2025-11-30 15:39:18 +01:00

58 lines
1.4 KiB
Docker

# Multi-stage build for Node.js frontend application
FROM node:iron-alpine3.22 AS builder
# Enable Corepack for Yarn 4.x
RUN corepack enable
# Set working directory
WORKDIR /app
# Copy Yarn configuration and package files
COPY .yarnrc.yml package.json yarn.lock ./
# Install dependencies (uses PnP by default from .yarnrc.yml)
RUN yarn install --immutable
# Copy source code
COPY . .
# Build the application
RUN yarn build
# Production stage
FROM node:iron-alpine3.22 AS production
# Enable Corepack for Yarn 4.x
RUN corepack enable
# Create app user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
# Set working directory
WORKDIR /app
# Copy Yarn configuration and package files
COPY .yarnrc.yml package.json yarn.lock ./
# Install production dependencies (uses PnP)
RUN yarn workspaces focus --production
# Copy PnP files and built application from builder stage
COPY --from=builder --chown=nextjs:nodejs /app/.pnp.cjs /app/.pnp.loader.mjs ./
COPY --from=builder --chown=nextjs:nodejs /app/.yarn ./.yarn
COPY --from=builder --chown=nextjs:nodejs /app/dist ./dist
# Switch to non-root user
USER nextjs
# Expose the application port
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))"
# Command to run the application
CMD ["yarn", "start"]