FROM    086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:python311 AS base

WORKDIR /var/app

# Update and install common packages
USER root

RUN apt update
RUN apt upgrade -y

RUN apt install -y which curl git tar zip openssl
RUN apt install -y default-jre build-essential supervisor default-mysql-client

ADD . /var/app

# Explicitly set locale and related env vars to use not default POSIX, but en_US.UTF-8
RUN apt install -y locales
RUN locale-gen en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8

RUN pip3.11 install --upgrade pip
RUN pip3.11 install -r reqs.pip
RUN pip3.11 install .

FROM base as deploy
# Run supervisord
ENTRYPOINT ["/usr/bin/supervisord", "-c", "conf/supervisor.conf"]
EXPOSE 9001

FROM base as unit-lint

COPY ./scripts/unit-lint.sh ./scripts/unit-lint.sh
RUN chmod +x ./scripts/unit-lint.sh
RUN pip3.11 install -r reqs-test.pip

ENTRYPOINT  ["scripts/unit-lint.sh"]
