# Default-deny egress proxy sidecar (test fixture, not a security boundary).
# host:'0.0.0.0' is REQUIRED here: the agent container reaches this sidecar across the docker network,
# not over loopback. startEgressProxy defaults to a loopback bind (see ProxyOptions.host).
# Built from the SHIPPED dist/ (no source checkout / TS build) so it works from an installed package.
FROM node:22-slim
WORKDIR /app
# package.json provides "type":"module". dist/egress/proxy.js uses Node built-ins (http/net/fs) plus
# one shared helper, dist/boundary-paths.js (validateBareDomain) — itself built-ins-only, so these two
# dist paths are the proxy's complete closure. Keep both COPYs in sync if proxy.js gains an import.
COPY package.json ./
COPY dist/egress ./dist/egress
COPY dist/boundary-paths.js ./dist/boundary-paths.js
ENV PORT=8080
# Entry runs the proxy standalone reading COWORK_ALLOW (comma-separated).
# COWORK_PROXY_LOG: where to write JSON decision lines (default stdout; the sidecar
# points it at a bind-mounted file so the CLI can read per-run egress decisions).
CMD ["node", "-e", "import('./dist/egress/proxy.js').then(m=>m.startEgressProxy({allow:(process.env.COWORK_ALLOW||'').split(',').filter(Boolean),host:'0.0.0.0',port:Number(process.env.PORT||8080),logPath:process.env.COWORK_PROXY_LOG||'/dev/stdout'}))"]
