FROM node:20-slim

WORKDIR /app

# Copy package files first for layer caching
COPY package.json package-lock.json ./

# Copy generalFunctions submodule (needed as local dependency)
COPY nodes/generalFunctions/ ./nodes/generalFunctions/

# Rewrite git+https dependency to local path (avoids needing Gitea credentials)
RUN sed -i 's|"generalFunctions": "git+https://[^"]*"|"generalFunctions": "file:./nodes/generalFunctions"|' package.json

RUN npm install --ignore-scripts

# Copy full source
COPY . .

# Default: run full CI suite
CMD ["npm", "run", "ci"]
