FROM                 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:python313
WORKDIR              /var/app

# Update and install common packages
USER                root
RUN                 apt-get update \
                      && apt-get -y upgrade \
                      && apt-get -y clean \
                      && rm -rf /var/lib/apt/lists/*

# Create and configure virtualenv and uwsgi
ENV                 VIRTUAL_ENV /var/venv
RUN                 python -m venv ${VIRTUAL_ENV}
ENV                 PATH "$VIRTUAL_ENV/bin:$PATH"

RUN                 pip install --upgrade pip

# Install common module
COPY --from=common  pyproject.toml README.md ./common/
COPY --from=common  common ./common/common
RUN                 pip install ./common -i https://pypi.theorchard.io/pypi/

# Add application and install requirements
COPY                app.py config.py docker-compose.yaml lint-and-test.sh requirements.txt requirements-test.txt .flake8 ./
COPY                tests/ ./tests
RUN                 if [ -f /var/app/requirements-test.txt ]; then pip install -I -r /var/app/requirements-test.txt; fi

USER                worker

ENTRYPOINT          [ "/var/app/lint-and-test.sh" ]
