From 7d2bb77b2443be73b44d0b58952f96a0fbfababe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Jun 2025 09:46:18 +0000 Subject: [PATCH 1/3] Initial plan for issue From 949a873a9c3c6b481d6ff13a0aa7212d3ec092ee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Jun 2025 09:56:10 +0000 Subject: [PATCH 2/3] Add Docker support: Dockerfile and .dockerignore for containerized deployment Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com> --- .dockerignore | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 59 ++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2b2a06e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,82 @@ +# Dependencies +node_modules/ +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Build output +dist/ +build/ + +# Git +.git/ +.gitignore + +# Environment files +.env +.env.* +!.env.example + +# IDE and editor files +.vscode/ +.idea/ +*.swp +*.swo + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Logs +logs/ +*.log + +# Runtime data +pids/ +*.pid +*.seed +*.pid.lock + +# Coverage directory +coverage/ +*.lcov + +# Temporary folders +tmp/ +temp/ + +# Documentation +docs/ +ai_context/ +README.md +CONTRIBUTING.md +CODE_OF_CONDUCT.md +LICENSE +SECURITY.md + +# Package manager files +package-lock.json +.yarn-integrity +.yarn/ + +# TypeScript +*.tsbuildinfo + +# Cache +.cache/ +.parcel-cache/ +.eslintcache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Testing +test/ +tests/ +__tests__/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6fae4c3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,59 @@ +# Multi-stage build for Unthread Webhook Server + +# Build stage +FROM node:20-alpine AS builder + +# Set working directory +WORKDIR /app + +# Copy package manager files +COPY package.json yarn.lock .yarnrc ./ + +# Install all dependencies (including devDependencies for building) +RUN yarn config set strict-ssl false && \ + yarn install --frozen-lockfile --ignore-scripts + +# Copy source code and build configuration +COPY src/ ./src/ +COPY tsconfig.json ./ + +# Build the TypeScript application +RUN yarn build + +# Production stage +FROM node:20-alpine AS production + +# Set working directory +WORKDIR /app + +# Copy package manager files +COPY package.json yarn.lock .yarnrc ./ + +# Install only production dependencies +RUN yarn config set strict-ssl false && \ + yarn install --frozen-lockfile --production --ignore-scripts && \ + yarn cache clean + +# Copy built application from builder stage +COPY --from=builder /app/dist ./dist + +# Copy environment example (for reference) +COPY .env.example ./ + +# Create non-root user for security +RUN addgroup -g 1001 -S nodejs && \ + adduser -S nodejs -u 1001 + +# Change ownership of the app directory to nodejs user +RUN chown -R nodejs:nodejs /app +USER nodejs + +# Expose the port the app runs on +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) })" + +# Start the application +CMD ["node", "dist/app.js"] \ No newline at end of file From 3762efab08d682b150cf55a525d881d97c4e3681 Mon Sep 17 00:00:00 2001 From: Waren Gonzaga Date: Sat, 21 Jun 2025 18:03:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E2=98=95=20chore:=20apply=20suggestions=20?= =?UTF-8?q?from=20code=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6fae4c3..7be3254 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,7 @@ WORKDIR /app COPY package.json yarn.lock .yarnrc ./ # Install all dependencies (including devDependencies for building) -RUN yarn config set strict-ssl false && \ - yarn install --frozen-lockfile --ignore-scripts +RUN yarn install --frozen-lockfile --ignore-scripts # Copy source code and build configuration COPY src/ ./src/ @@ -29,6 +28,8 @@ WORKDIR /app # Copy package manager files COPY package.json yarn.lock .yarnrc ./ +# Set environment to production +ENV NODE_ENV=production # Install only production dependencies RUN yarn config set strict-ssl false && \ yarn install --frozen-lockfile --production --ignore-scripts && \ @@ -53,7 +54,7 @@ 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) })" + CMD node -e "require('http').get('http://localhost:3000/health', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) }).on('error', () => process.exit(1))" # Start the application CMD ["node", "dist/app.js"] \ No newline at end of file