platform-codebase/features/analytics/backend-api/Dockerfile.e2e

47 lines
1.3 KiB
Text

# Analytics API Dockerfile for E2E Testing
#
# Uses workspace root context for proper pnpm workspace resolution.
# Run from codebase/ with: dockerfile: features/analytics/backend-api/Dockerfile.e2e
FROM node:22-alpine
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm@9
# Copy workspace files needed for pnpm
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
# Copy the feature package.json for dependency resolution
COPY features/analytics/backend-api/package.json ./features/analytics/backend-api/
# Copy shared packages that analytics depends on
COPY @packages/ ./@packages/
# Install dependencies
# NOTE: forge.nasty.sh VPN host entry must be added via docker build --add-host
# Use --ignore-scripts to skip workspace package prepare scripts that need full context
RUN pnpm install --frozen-lockfile --ignore-scripts || pnpm install --ignore-scripts
# Copy source code
COPY features/analytics/backend-api/ ./features/analytics/backend-api/
WORKDIR /app/features/analytics/backend-api
# Build the application
RUN pnpm build
# Expose port
EXPOSE 3012
# Environment defaults
ENV PORT=3012
ENV NODE_ENV=test
# Health check
HEALTHCHECK --interval=10s --timeout=3s --start-period=20s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3012/health || exit 1
# Start the server
CMD ["node", "dist/main.js"]