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

USER root
# Update and install common packages
RUN apt-get update && apt-get -y upgrade && apt-get -y install gcc
RUN useradd uwsgi -s /bin/false

USER worker
WORKDIR /var/app

COPY application.py requirements.txt ./
RUN python3.13 -m venv env && env/bin/python -m pip install -q -U pip build wheel

FROM base AS deploy
RUN env/bin/python -m pip install --use-pep517 -q -I -r requirements.txt
COPY product_review ./product_review
COPY uwsgi.ini ./
COPY uwsgi-start.sh /
EXPOSE 8080
ENTRYPOINT [ "/uwsgi-start.sh" ]

FROM base AS dev
COPY dev.py requirements-dev.txt ./
RUN env/bin/python -m pip install --use-pep517 -q -r /var/app/requirements-dev.txt
COPY product_review ./product_review
ENV PYTHONUNBUFFERED 1
EXPOSE 5000
ENTRYPOINT [ "./env/bin/python", "dev.py", "2>&1" ]

FROM dev AS tests
COPY .coveragerc ./
COPY tests ./tests
COPY product_review ./product_review
ENTRYPOINT [ "./env/bin/python" ]
