Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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__/
5 changes: 5 additions & 0 deletions .env.docker.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
NODE_ENV=production
PORT=3000
REDIS_URL=redis://host.docker.internal:6379
TARGET_PLATFORM=telegram
UNTHREAD_WEBHOOK_SECRET=your_docker_webhook_secret_here
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NODE_ENV=development
NODE_ENV=production
PORT=3000
TARGET_PLATFORM=telegram
REDIS_URL=redis://localhost:6379
UNTHREAD_WEBHOOK_SECRET=your_signing_secret_here
TARGET_PLATFORM=telegram
UNTHREAD_WEBHOOK_SECRET=your_production_webhook_secret_here
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ ai_context/

# Enforce Yarn usage - ignore npm lockfile
package-lock.json

# Environment files with sensitive data
.env
.env.docker
.env.test
.env.local
.env.*.local
.env.production
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 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 ./

# Set environment to production
ENV NODE_ENV=production
# Install only production dependencies
RUN 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) }).on('error', () => process.exit(1))"

# Start the application
CMD ["node", "dist/app.js"]
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ Server runs on `http://localhost:3000` with endpoints:
- `GET /health` - Health check
- `POST /unthread-webhook` - Webhook endpoint

## 🐳 Docker Setup

```bash
# Copy Docker template
cp .env.docker.example .env.docker
# Edit .env.docker with your secrets

# Start Redis for Docker
docker run -d --name docker-redis -p 6379:6379 redis:7-alpine

# Run with Docker (using cloud builder)
docker run --name docker-unthread-webhook-server --env-file .env.docker -p 3000:3000 --rm wgtechlabs/unthread-webhook-server:latest
```

**Environment Files:**

- `.env` - Local development (Node.js directly)
- `.env.docker` - Docker testing (`redis://host.docker.internal:6379`)
- `.env.example` + `.env.docker.example` - Safe templates (committed to git)

## ⚙️ Configuration

### Environment Variables
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unthread-webhook-server",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"description": "A Node.js server application that receives webhook events from Unthread.io and queues them for processing.",
"license": "GPL-3.0",
"private": true,
Expand Down