FROM python:3.10.10-buster  AS builder
ARG UID=1000
ARG GID=1000
ARG USERNAME=container-user
RUN groupadd --gid ${GID} ${USERNAME} \
    && useradd --uid ${UID} --gid ${GID} -m ${USERNAME} \
    && apt-get update \
    && apt-get install -y sudo bash gettext poppler-utils \
    && echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
    && chmod 0440 /etc/sudoers.d/${USERNAME}
RUN yes | apt install postgresql gcc musl-dev
RUN pip install --upgrade pip
RUN pip install uvicorn gunicorn Celery

USER ${UID}
ADD --chown=${UID}:${GID} fwd /app
COPY --chown=${UID}:${GID} requirements.txt /app

WORKDIR /app
RUN pip install -r requirements.txt --no-cache-dir

COPY --chown=${UID}:${GID} . /app

ENV TZ="Asia/Ho_Chi_Minh"