# Multi-stage build for Hono API FROM node:20-alpine AS base WORKDIR /app # Install dependencies FROM base AS deps COPY package.json ./ RUN npm install # Build TypeScript FROM base AS builder COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npm run build # Production image FROM base AS runner ENV NODE_ENV=production # Copy built files and production dependencies COPY --from=builder /app/dist ./dist COPY --from=deps /app/node_modules ./node_modules COPY package.json ./ # Health check HEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=40s \ CMD node -e "require('http').get('http://127.0.0.1:3000/health', (r) => r.statusCode === 200 ? process.exit(0) : process.exit(1))" EXPOSE 3000 CMD ["npm", "start"]