FROM python:3.7-buster

ARG APP
ARG PACKAGE
ARG SERVICE_PORT

RUN apt-get update
RUN apt-get install gcc libc-dev python3-dev supervisor bash --no-install-recommends -y

# Copy requirements
COPY ./requirements.txt /app/requirements.txt
COPY ./requirements /app/requirements

# Copy pip configs for private repo
RUN mkdir -p /root/.config/pip/
COPY pip.conf /root/.config/pip/
COPY .pypirc /root/

WORKDIR /app

# Install any needed packages specified in requirements.txt
RUN pip install --upgrade pip setuptools
RUN pip install -r requirements.txt

COPY . /app

RUN pip install -e .

COPY conf/supervisor/supervisord.conf /etc/supervisor/
COPY conf/supervisor/*.conf /etc/supervisor/conf.d/

EXPOSE ${SERVICE_PORT}

CMD ["/app/bin/entrypoint.sh"]
