CRITICAL FIX: Frontend was serving raw CSS with uncompiled @tailwind directives, resulting in completely unstyled pages (plain text without any CSS). Root cause: - postcss.config.js and tailwind.config.js/ts were excluded in .dockerignore - This prevented PostCSS/Tailwind from compiling CSS during Docker builds - Local builds worked because config files were present Changes: 1. apps/frontend/.dockerignore: - Commented out postcss.config.js exclusion - Commented out tailwind.config.js/ts exclusions - Added explanatory comments about why these files are needed 2. apps/backend/Dockerfile: - Copy src/ directory to production stage for CSV upload paths - Create csv-storage/rates directory with proper permissions - Fix EACCES errors when uploading CSV files 3. apps/backend/src/application/controllers/admin/csv-rates.controller.ts: - Add getCsvUploadPath() helper function - Support both local dev and Docker environments - Use absolute paths instead of relative paths 4. docker-compose.dev.yml: - Change backend port mapping to 4001:4000 (avoid local dev conflicts) - Change frontend port mapping to 3001:3000 - Update CORS_ORIGIN and NEXT_PUBLIC_API_URL accordingly Impact: - ✅ Fixes completely broken frontend CSS in Docker/production - ✅ Applies to CI/CD builds (uses apps/frontend/.dockerignore) - ✅ Applies to Portainer deployments (pulls from CI/CD images) - ✅ Fixes CSV upload permission errors in backend - ✅ Enables local Docker testing on Mac ARM64 Testing: - Local Docker build now shows compiled Tailwind CSS (60KB+) - Frontend displays properly styled pages at http://localhost:3001 - Backend CSV uploads work without permission errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
85 lines
2.2 KiB
Docker
85 lines
2.2 KiB
Docker
# ===============================================
|
|
# Stage 1: Dependencies Installation
|
|
# ===============================================
|
|
FROM node:20-alpine AS dependencies
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache python3 make g++ libc6-compat
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
COPY tsconfig*.json ./
|
|
|
|
# Install all dependencies (including dev for build)
|
|
RUN npm install --legacy-peer-deps
|
|
|
|
# ===============================================
|
|
# Stage 2: Build Application
|
|
# ===============================================
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy dependencies from previous stage
|
|
COPY --from=dependencies /app/node_modules ./node_modules
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Remove dev dependencies to reduce size
|
|
RUN npm prune --production --legacy-peer-deps
|
|
|
|
# ===============================================
|
|
# Stage 3: Production Image
|
|
# ===============================================
|
|
FROM node:20-alpine AS production
|
|
|
|
# Install dumb-init for proper signal handling
|
|
RUN apk add --no-cache dumb-init
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
adduser -S nestjs -u 1001
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy built application from builder
|
|
COPY --from=builder --chown=nestjs:nodejs /app/dist ./dist
|
|
COPY --from=builder --chown=nestjs:nodejs /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=nestjs:nodejs /app/package*.json ./
|
|
|
|
# Copy source code needed at runtime (for CSV storage path resolution)
|
|
COPY --from=builder --chown=nestjs:nodejs /app/src ./src
|
|
|
|
# Create logs and uploads directories
|
|
RUN mkdir -p /app/logs && \
|
|
mkdir -p /app/src/infrastructure/storage/csv-storage/rates && \
|
|
chown -R nestjs:nodejs /app/logs /app/src
|
|
|
|
# Switch to non-root user
|
|
USER nestjs
|
|
|
|
# Expose port
|
|
EXPOSE 4000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD node -e "require('http').get('http://localhost:4000/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"
|
|
|
|
# Set environment variables
|
|
ENV NODE_ENV=production \
|
|
PORT=4000
|
|
|
|
# Use dumb-init to handle signals properly
|
|
ENTRYPOINT ["dumb-init", "--"]
|
|
|
|
# Start the application
|
|
CMD ["node", "dist/main"]
|