# The image ci/run-traffic-parrot.sh builds when TRAFFIC_PARROT_DOCKER=true: the Traffic Parrot
# release zip with this repository's files copied in, so the container needs no bind mount (a CI
# runner that talks to a shared Docker daemon cannot mount its own directories). The script copies
# the zip, the files and the licence (if any) into the build context next to this file.
FROM eclipse-temurin:21-jre

RUN apt-get update && apt-get install -y --no-install-recommends unzip && rm -rf /var/lib/apt/lists/*

WORKDIR /opt
COPY trafficparrot.zip trafficparrot.zip
RUN unzip -q trafficparrot.zip && rm trafficparrot.zip && mv trafficparrot-* trafficparrot
COPY licence/ trafficparrot/
COPY traffic-files/ traffic-files/

WORKDIR /opt/trafficparrot
ENV TRAFFIC_PARROT_HTTP_PORT=8081
ENV TRAFFIC_PARROT_GUI_PORT=8080
CMD exec ./start-foreground.sh \
    trafficparrot.virtualservice.trafficFilesRootUrl=file:/opt/traffic-files \
    trafficparrot.virtualservice.http.port=$TRAFFIC_PARROT_HTTP_PORT \
    trafficparrot.gui.http.port=$TRAFFIC_PARROT_GUI_PORT
