FROM nats:2.10.22-alpine

ENV TACTICAL_DIR /opt/tactical
ENV TACTICAL_READY_FILE ${TACTICAL_DIR}/tmp/tactical.ready

RUN apk add --no-cache supervisor bash

SHELL ["/bin/bash", "-e", "-o", "pipefail", "-c"]

COPY natsapi/bin/nats-api /usr/local/bin/
RUN chmod +x /usr/local/bin/nats-api

RUN touch /usr/local/bin/config_watcher.sh
RUN chown 1000:1000 /usr/local/bin/config_watcher.sh

RUN mkdir -p /var/log/supervisor
RUN mkdir -p /etc/supervisor/conf.d
RUN touch /etc/supervisor/conf.d/supervisor.conf
RUN chown 1000:1000 /etc/supervisor/conf.d/supervisor.conf

COPY docker/containers/tactical-nats/entrypoint.sh /
RUN chmod +x /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]

USER 1000

EXPOSE 4222 9235
