Files
url_tracker_tool/apps/worker/Dockerfile
Andrei 956f1aeadb feat(phase-0): setup Docker Compose with TypeScript monorepo structure
- Create monorepo structure with apps/ and packages/
- Add Docker Compose for api, web, db, redis, worker services
- Migrate existing Express.js logic to TypeScript with 100% backward compatibility
- Preserve all existing API endpoints (/api/track, /api/v1/track) with identical behavior
- Setup development environment with hot reload and proper networking
- Add comprehensive TypeScript configuration with path mapping
- Include production-ready Dockerfiles with multi-stage builds
- Maintain existing rate limiting (100 req/hour/IP) and response formats
- Add health checks and graceful shutdown handling
- Setup Turbo for efficient monorepo builds and development
2025-08-18 07:03:08 +00:00

62 lines
1.3 KiB
Docker

# Multi-stage build for production optimization
FROM node:20-alpine AS base
# Install Playwright dependencies
RUN apk add --no-cache \
chromium \
nss \
freetype \
freetype-dev \
harfbuzz \
ca-certificates \
ttf-freefont
# Tell Playwright to use the installed chromium
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium-browser
# Development stage
FROM base AS dev
WORKDIR /app
# Copy package files
COPY package*.json ./
COPY apps/worker/package*.json ./apps/worker/
COPY packages/database/package*.json ./packages/database/
COPY packages/shared/package*.json ./packages/shared/
# Install all dependencies
RUN npm ci
# Copy source code
COPY apps/worker ./apps/worker
COPY packages/database ./packages/database
COPY packages/shared ./packages/shared
WORKDIR /app/apps/worker
CMD ["npm", "run", "dev"]
# Production stage
FROM base AS production
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
COPY apps/worker ./apps/worker
COPY packages/database ./packages/database
COPY packages/shared ./packages/shared
# Install dependencies and build
RUN npm ci --only=production
WORKDIR /app/apps/worker
RUN npm run build
# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nodejs
USER nodejs
CMD ["npm", "start"]