mirror of
https://github.com/SamyRai/tercul-frontend.git
synced 2025-12-27 00:11:35 +00:00
* feat: Add GitHub Actions workflows for frontend CI/CD - Add lint.yml: TypeScript and ESLint checks - Add build.yml: Vite application build pipeline - Add docker-build.yml: Multi-arch container image builds - Add deploy.yml: Production deployment to Docker Swarm - Add dependabot.yml: Automated dependency updates Follows Single Responsibility Principle with focused workflows. Includes security best practices, caching, and deployment automation. * fix: Add missing Dockerfile and lint script for CI/CD workflows - Add Dockerfile for multi-stage Node.js build with production optimizations - Add lint script to package.json that runs TypeScript type checking - Enable health check endpoint in Docker container - Configure proper user permissions and security practices Fixes docker-build workflow failures and enables complete CI/CD pipeline. * fix: Enable Corepack for Yarn 4.x compatibility in Docker build - Enable Corepack in Dockerfile to support packageManager field - Fix lint script to use TypeScript checking instead of invalid yarn check - Remove manual yarn installation from Dockerfile since Corepack handles it * fix: Enable Corepack in CI workflows to resolve Yarn version conflicts * chore: Update to latest GitHub Actions versions - Update actions/checkout to v6 - Update actions/setup-node to v6 - Update actions/upload-artifact to v5 - Update Node.js to version 22 (Active LTS) - Update Docker base images to node:22-alpine * Fix Corepack/Yarn caching issue in CI workflows - Remove cache: yarn from setup-node action to prevent yarn usage before corepack enable - Enable corepack immediately after Node.js setup - Add manual yarn caching using actions/cache@v4 with proper cache directory path - This resolves the packageManager field conflict in CI * Fix BlogEdit.tsx import and component issues - Fix import path from @/api/blog-api to @/lib/api/blog-api - Replace TagManager component with simple tag input since BlogEdit uses plain state - Remove unused handleTagsChange function - This resolves the build error where blog-api file was not found * Fix Yarn 4.x deprecated commands in Dockerfile - Replace --frozen-lockfile with --immutable in builder stage - Replace --frozen-lockfile --production with --immutable + autoclean in production stage - This resolves the Yarn 4.9.0 deprecation warnings and build failures * fix: optimize Dockerfile to use Yarn PnP instead of node-modules - Use Yarn Plug'n'Play (PnP) for faster installs and smaller image size - Keep .yarnrc.yml configuration instead of overriding it - Copy PnP files (.pnp.cjs, .pnp.loader.mjs, .yarn cache) to production stage - Use yarn workspaces focus --production for production dependencies - Corepack manages Yarn version while PnP handles dependency resolution * fix: correct CI/CD workflow issues - Fix lint.yml to use 'yarn check' instead of 'yarn lint' (ESLint not configured) - Fix Dockerfile to use 'yarn install --production' for single package repo - Update workflow name to reflect actual functionality
58 lines
1.5 KiB
Docker
58 lines
1.5 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 install --immutable --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"]
|