fix: deployment issues and add health check

main
borja (aider) 3 months ago
parent 2e40bd8522
commit 027e11523e

@ -1,16 +1,21 @@
# Use official Bun image for optimal performance
FROM oven/bun:1.1 as base
# Use official Bun image with Alpine for smaller size
FROM oven/bun:1.1-alpine as base
WORKDIR /app
# Install dependencies first (better layer caching)
COPY package.json ./
RUN bun install
COPY package.json bun.lock ./
RUN bun install --production
# Copy all source files
COPY . .
# Copy only necessary files
COPY src/ ./src/
COPY index.ts ./
# Server runs on port 3007 by default (override with PORT env var)
# Health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:3007/health || exit 1
# Server runs on port 3007 by default
EXPOSE 3007
# Start the server (env vars will be injected by CapRover)
# Start the server
CMD ["bun", "run", "index.ts"]

@ -4,8 +4,9 @@ console.log("Starting WhatsApp Task Bot...");
try {
const server = WebhookServer.start();
console.log("Server started successfully");
export default server;
} catch (error) {
console.error("Failed to start server:", error);
process.exit(1);
}
export default WebhookServer;

@ -24,6 +24,11 @@ type WebhookPayload = {
export class WebhookServer {
static async handleRequest(request: Request): Promise<Response> {
// Health check endpoint
if (request.url.endsWith('/health')) {
return new Response('OK', { status: 200 });
}
// 1. Method validation
if (request.method !== 'POST') {
return new Response('Method not allowed', { status: 405 });

Loading…
Cancel
Save