FROM oven/bun:latest@sha256:9114c058aeae42162ee16dd5084b95fe9473970bb6bcb5b232ab1630f0546895

# iproute2 so the entrypoint can see its own addressing when debugging; the
# service itself needs no routing changes (it sits on internet-external with
# the other public simulators and answers requests that arrive there).
RUN apt-get update && apt-get install -y iproute2 curl \
    && rm -rf /var/lib/apt/lists/*

COPY simulators/ip-echo/server.ts /simulator/server.ts

# Route the customer's public prefix via the ISP edge, like every other host
# on internet-external. Without it a reply to the customer's WAN address goes
# to Docker's bridge gateway, which has no path across networks, and the
# connection simply hangs. See config/routing/public-sim-entrypoint.sh.
COPY config/routing/public-sim-entrypoint.sh /usr/local/bin/public-sim-entrypoint.sh

WORKDIR /simulator
EXPOSE 80
ENTRYPOINT ["/bin/sh", "/usr/local/bin/public-sim-entrypoint.sh"]
CMD ["bun", "run", "server.ts"]
