ARG PARENT_IMAGE=086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:python313
FROM $PARENT_IMAGE AS parent

USER root

RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y locales

ENTRYPOINT ["/bin/bash"]
# Misc system setup.
RUN useradd storeavailability -s /bin/false

# Explicitly set locale and related env vars to use not default POSIX, but en_US.UTF-8
RUN localedef -c -f UTF-8 -i en_US en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8

# Download iTMSTransporter & Install iTMSTransporter.
RUN curl -sL -o iTMSTransporter_installer.sh https://orcd-public.theorchard.io/Technology/iTMSTransporter_installer_linux_x64_4.2.0.16.sh \
      && chmod 700 iTMSTransporter_installer.sh

RUN pip3.13 install -U pip setuptools
RUN pip3.13 install awscli
RUN pip3.13 install pexpect

ADD ./daemon/run_transporter_installer.py .
RUN python3.13 run_transporter_installer.py iTMSTransporter_installer.sh

# Auto update
RUN /usr/local/itms/bin/iTMSTransporter -version \
      && rm iTMSTransporter_installer.sh \
      && rm run_transporter_installer.py

WORKDIR /var/app

ADD . /var/app/

# Install system-level Python packages.
RUN python3.13 -m venv ./venv
RUN /var/app/venv/bin/python -m pip install --upgrade pip setuptools
RUN /var/app/venv/bin/pip install -r /var/app/requirements.txt

ENTRYPOINT ["/var/app/venv/bin/ddtrace-run", "/var/app/venv/bin/python", "/var/app/main.py"]

EXPOSE     9001
