ARG NAMESPACE=selenium
ARG VERSION=latest
FROM ${NAMESPACE}/base:${VERSION}
ARG AUTHORS
LABEL authors=${AUTHORS}

USER root

#==============
# Socat to proxy docker.sock when mounted
#==============
RUN apt-get update -qqy \
  && apt-get -qqy --no-install-recommends install socat \
  && rm -rf /var/lib/apt/lists/* /var/cache/apt/*

USER ${SEL_UID}

#========================
# Selenium Standalone Docker Configuration
#========================

EXPOSE 4444

COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-docker.sh \
    start-socat.sh \
    /opt/bin/

COPY --chown="${SEL_UID}:${SEL_GID}" config.toml /opt/selenium/docker.toml

COPY selenium-grid-docker.conf /etc/supervisor/conf.d/

ENV SE_OTEL_SERVICE_NAME="selenium-node-docker" \
    SE_EVENT_BUS_PUBLISH_PORT="4442" \
    SE_EVENT_BUS_SUBSCRIBE_PORT="4443" \
    SE_NODE_DOCKER_CONFIG_FILENAME="docker.toml" \
    SE_NODE_ENABLE_MANAGED_DOWNLOADS="true" \
    SE_DYNAMIC_MAX_SESSIONS="" \
    SE_DYNAMIC_OVERRIDE_MAX_SESSIONS=""