## Image to build from sources

FROM python:3.9-slim-bullseye
MAINTAINER XiVO Team "dev@avencall.com"

ENV DEBIAN_FRONTEND noninteractive
ENV HOME /root

# Add dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends --auto-remove \
    git \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install xivo-agid
WORKDIR /usr/src/agid

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
RUN python setup.py install

# Configure environment
RUN adduser --disabled-password --gecos '' asterisk
RUN touch /var/log/xivo-agid.log
RUN mkdir -p /etc/xivo-agid/conf.d/
RUN mkdir /var/lib/xivo-agid

RUN cp -a etc/xivo-agid/* /etc/xivo-agid/
RUN cp -a 010-mds.yml /etc/xivo-agid/conf.d/
RUN cp -a boot.sh /var/lib/xivo-agid/
WORKDIR /root

# Clean
RUN rm -rf /usr/src/agid

# Version
ARG TARGET_VERSION
LABEL version=${TARGET_VERSION}

EXPOSE 4573
CMD ["/var/lib/xivo-agid/boot.sh"]
