2026-01-29 21:56:49 -08:00
|
|
|
# Profile Backend API Dockerfile for E2E Testing
|
|
|
|
|
#
|
|
|
|
|
# Builds and runs the NestJS backend API for E2E tests.
|
|
|
|
|
#
|
|
|
|
|
# Build from the profile directory:
|
|
|
|
|
# docker build -f e2e/Dockerfile.api -t profile-api-e2e .
|
|
|
|
|
|
2026-01-29 23:41:36 -08:00
|
|
|
FROM node:20-slim
|
2026-01-29 21:56:49 -08:00
|
|
|
|
|
|
|
|
# Install pnpm and wget for health checks
|
2026-01-29 23:41:36 -08:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends wget && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/* && \
|
2026-01-29 21:56:49 -08:00
|
|
|
corepack enable && corepack prepare pnpm@8.15.0 --activate
|
|
|
|
|
|
|
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Configure npm registry (set via build arg)
|
2026-01-29 22:55:54 -08:00
|
|
|
# Default to localhost:4874 (local Verdaccio) for dev builds
|
|
|
|
|
ARG NPM_REGISTRY=http://localhost:4874/
|
2026-01-29 21:56:49 -08:00
|
|
|
RUN npm config set registry ${NPM_REGISTRY} && \
|
2026-01-29 23:29:26 -08:00
|
|
|
pnpm config set registry ${NPM_REGISTRY} && \
|
|
|
|
|
pnpm config set shamefully-hoist true
|
2026-01-29 21:56:49 -08:00
|
|
|
|
|
|
|
|
# Copy package files for backend (from context: codebase/features/profile/)
|
|
|
|
|
COPY backend-api/package.json ./
|
|
|
|
|
COPY backend-api/pnpm-lock.yaml* ./
|
|
|
|
|
|
|
|
|
|
# Install dependencies
|
2026-01-29 22:55:54 -08:00
|
|
|
RUN pnpm install --no-frozen-lockfile
|
2026-01-29 21:56:49 -08:00
|
|
|
|
|
|
|
|
# Copy backend source
|
|
|
|
|
COPY backend-api/ ./
|
|
|
|
|
|
2026-01-29 23:35:39 -08:00
|
|
|
# Find nest.js in pnpm store
|
|
|
|
|
RUN find node_modules -name "nest.js" -path "*cli/bin*" 2>/dev/null | head -5
|
2026-01-29 23:29:26 -08:00
|
|
|
|
2026-01-29 23:35:39 -08:00
|
|
|
# Build using found path
|
|
|
|
|
RUN node $(find node_modules -name "nest.js" -path "*cli/bin*" 2>/dev/null | head -1) build
|
2026-01-29 21:56:49 -08:00
|
|
|
|
|
|
|
|
# Set environment
|
|
|
|
|
ENV NODE_ENV=test
|
|
|
|
|
ENV PORT=3110
|
|
|
|
|
|
|
|
|
|
# Expose port
|
|
|
|
|
EXPOSE 3110
|
|
|
|
|
|
|
|
|
|
# Run the API (adjust path based on NestJS build output)
|
|
|
|
|
CMD ["node", "dist/main.js"]
|