From 39d8a4ef3d8cef215a7b44d03d47eeb44685563f Mon Sep 17 00:00:00 2001 From: Damir Mukimov Date: Thu, 27 Nov 2025 04:54:10 +0100 Subject: [PATCH] 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. --- Dockerfile | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cd0ee66 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,55 @@ +# Multi-stage build for Node.js frontend application +FROM node:20-alpine AS builder + +# Install yarn +RUN apk add --no-cache yarn + +# Set working directory +WORKDIR /app + +# Copy package files +COPY package.json yarn.lock ./ + +# Install dependencies +RUN yarn install --frozen-lockfile + +# Copy source code +COPY . . + +# Build the application +RUN yarn build + +# Production stage +FROM node:20-alpine AS production + +# Install yarn for production +RUN apk add --no-cache yarn + +# Create app user +RUN addgroup -g 1001 -S nodejs +RUN adduser -S nextjs -u 1001 + +# Set working directory +WORKDIR /app + +# Copy package files +COPY package.json yarn.lock ./ + +# Install only production dependencies +RUN yarn install --frozen-lockfile --production && yarn cache clean + +# Copy built application from builder stage +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"] diff --git a/package.json b/package.json index 586d67a..7c3f50b 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "dev": "NODE_ENV=development tsx server/index.ts", "build": "vite build && esbuild server/index.ts --platform=node --packages=external --bundle --format=esm --outdir=dist", "start": "NODE_ENV=production node dist/index.js", - "check": "tsc" + "check": "tsc", + "lint": "yarn check" }, "dependencies": { "@anthropic-ai/sdk": "^0.37.0",