49 lines
1.4 KiB
Text
49 lines
1.4 KiB
Text
# 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 .
|
|
|
|
FROM node:20-slim
|
|
|
|
# Install pnpm and wget for health checks
|
|
RUN apt-get update && apt-get install -y --no-install-recommends wget && \
|
|
rm -rf /var/lib/apt/lists/* && \
|
|
corepack enable && corepack prepare pnpm@8.15.0 --activate
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Configure npm registry (set via build arg)
|
|
# Default to localhost:4874 (local Verdaccio) for dev builds
|
|
ARG NPM_REGISTRY=http://localhost:4874/
|
|
RUN npm config set registry ${NPM_REGISTRY} && \
|
|
pnpm config set registry ${NPM_REGISTRY} && \
|
|
pnpm config set shamefully-hoist true
|
|
|
|
# Copy package files for backend (from context: codebase/features/profile/)
|
|
COPY backend-api/package.json ./
|
|
COPY backend-api/pnpm-lock.yaml* ./
|
|
|
|
# Install dependencies
|
|
RUN pnpm install --no-frozen-lockfile
|
|
|
|
# Copy backend source
|
|
COPY backend-api/ ./
|
|
|
|
# Find nest.js in pnpm store
|
|
RUN find node_modules -name "nest.js" -path "*cli/bin*" 2>/dev/null | head -5
|
|
|
|
# Build using found path
|
|
RUN node $(find node_modules -name "nest.js" -path "*cli/bin*" 2>/dev/null | head -1) build
|
|
|
|
# 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"]
|