FROM node:22.22.2-bookworm

WORKDIR /app

COPY package*.json ./
RUN npm install -g @openai/codex && npm ci --legacy-peer-deps

COPY tsconfig.json ./
COPY scripts ./scripts
COPY src ./src

RUN npm run build

COPY scripts/container-supervisor.sh /usr/local/bin/work-server-supervisor
RUN chmod +x /usr/local/bin/work-server-supervisor

CMD ["/usr/local/bin/work-server-supervisor"]
