72 lines
2.7 KiB
Text
Executable file
72 lines
2.7 KiB
Text
Executable file
# Merchant API Dockerfile for E2E Testing
|
|
#
|
|
# Uses workspace root as build context (contains pnpm-lock.yaml).
|
|
# Run from backend-api/ with: docker compose -f docker-compose.e2e.yml up
|
|
|
|
FROM node:22-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Install pnpm and wget for healthchecks
|
|
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
|
RUN apk add --no-cache wget
|
|
|
|
# Registry configuration (from docker-compose build args)
|
|
ARG NPM_REGISTRY=http://npm.nasty.sh/
|
|
RUN echo "@lilith:registry=${NPM_REGISTRY}" > .npmrc && \
|
|
echo "strict-ssl=false" >> .npmrc
|
|
|
|
# Copy workspace files needed for pnpm (workspace root has pnpm-lock.yaml)
|
|
COPY codebase/pnpm-lock.yaml ./
|
|
COPY codebase/package.json ./package.json
|
|
|
|
# Create minimal pnpm-workspace.yaml (only merchant-api)
|
|
RUN echo 'packages:' > pnpm-workspace.yaml && \
|
|
echo ' - "features/merchant/backend-api"' >> pnpm-workspace.yaml
|
|
|
|
# Remove all workspace:* dependencies from root package.json (not needed for E2E)
|
|
RUN sed -i '/"workspace:/d' ./package.json
|
|
|
|
# Fix Verdaccio uplink issue: update eslint-plugin-import-alias to 1.1.1 (available on Forge)
|
|
# Version 1.1.0 fails with "uplink is offline" error
|
|
RUN sed -i 's/@lilith\/eslint-plugin-import-alias.*/@lilith\/eslint-plugin-import-alias": "1.1.1",/' ./package.json
|
|
|
|
# Copy tsconfig.base.json for TypeScript extends
|
|
COPY codebase/tsconfig.base.json ./
|
|
|
|
# Copy the feature package.json for dependency resolution
|
|
COPY codebase/features/merchant/backend-api/package.json ./features/merchant/backend-api/
|
|
|
|
# Remove unused workspace dependencies (@lilith/config and @lilith/types are not imported in src/)
|
|
RUN sed -i '/@lilith\/config/d' ./features/merchant/backend-api/package.json && \
|
|
sed -i '/@lilith\/types/d' ./features/merchant/backend-api/package.json
|
|
|
|
# Install dependencies (only merchant-api, no workspace deps needed)
|
|
# NOTE: forge.nasty.sh VPN host entry must be added via docker build --add-host
|
|
RUN pnpm install --no-frozen-lockfile --ignore-scripts
|
|
|
|
# Copy E2E infrastructure config (required by @lilith/service-addresses)
|
|
COPY codebase/features/merchant/backend-api/test/fixtures/infrastructure/ /infrastructure/
|
|
|
|
# Copy source code and tests
|
|
COPY codebase/features/merchant/backend-api/ ./features/merchant/backend-api/
|
|
|
|
WORKDIR /app/features/merchant/backend-api
|
|
|
|
# Build the application
|
|
RUN pnpm build
|
|
|
|
# Expose port
|
|
EXPOSE 3020
|
|
|
|
# Environment defaults
|
|
ENV PORT=3020
|
|
ENV NODE_ENV=test
|
|
ENV DATABASE_SYNCHRONIZE=false
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=5s --timeout=3s --start-period=20s --retries=10 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3020/health || exit 1
|
|
|
|
# Start the server (CMD can be overridden by docker-compose for e2e-tests container)
|
|
CMD ["node", "dist/main.js"]
|