From 042479aa721d0a38341d5bee069e2bc929eb5741 Mon Sep 17 00:00:00 2001 From: Brian O'Kelley Date: Thu, 4 Sep 2025 11:21:32 -0400 Subject: [PATCH] Fix Fly.io deployment timeout issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace TCP health checks with HTTP health checks pointing to /health endpoint - Update Dockerfile to properly build TypeScript and use correct server files - Fix default port consistency (8080) across all configuration files - Use npm start command for proper production deployment 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- Dockerfile | 16 ++++++++-------- fly.toml | 6 +++++- server.js | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8b85afbdd..1fda4a37f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,16 @@ # Use Node.js 18 Alpine for smaller image size FROM node:18-alpine AS base -# Install dependencies only when needed +# Install dependencies and dev dependencies for building FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app # Copy package files COPY package.json package-lock.json* ./ -RUN npm ci --only=production +RUN npm ci -# Build the source code (JavaScript version) +# Build the TypeScript source code FROM base AS builder WORKDIR /app @@ -18,7 +18,8 @@ WORKDIR /app COPY . . COPY --from=deps /app/node_modules ./node_modules -# No build needed - we're using plain JavaScript +# Build TypeScript +RUN npm run build # Production image FROM base AS runner @@ -28,9 +29,8 @@ WORKDIR /app RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 adcp -# Copy application files -COPY --from=builder /app/server.js ./server.js -COPY --from=builder /app/src ./src +# Copy built application files +COPY --from=builder /app/dist ./dist COPY --from=deps /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json @@ -49,4 +49,4 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD node -e "require('http').get('http://localhost:8080/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))" # Start the server -CMD ["node", "server.js"] \ No newline at end of file +CMD ["npm", "start"] \ No newline at end of file diff --git a/fly.toml b/fly.toml index f34145022..55ca3e548 100644 --- a/fly.toml +++ b/fly.toml @@ -33,10 +33,14 @@ primary_region = 'iad' port = 443 handlers = ['tls', 'http'] - [[services.tcp_checks]] + [[services.http_checks]] interval = '15s' timeout = '2s' grace_period = '10s' + method = 'get' + path = '/health' + protocol = 'http' + tls_skip_verify = false [[vm]] cpu_kind = 'shared' diff --git a/server.js b/server.js index 5336c7ca1..9581ef323 100644 --- a/server.js +++ b/server.js @@ -12,7 +12,7 @@ const cors = require('cors'); const { SalesAgentsHandlers } = require('./src/sales-agents-handlers-node'); const app = express(); -const port = process.env.PORT || 3000; +const port = process.env.PORT || 8080; // Middleware app.use(cors({