# xivo/xivo-dird-db (see Makefile)

ARG VERSION
FROM xivoxc/xivo-db:${VERSION}
LABEL maintainer="XiVO R&D Team rannd@xivo.solutions"

RUN apt-get -yq update \
   && apt-get -yqq install \
      build-essential \
      git \
      python3-dev \
      python3-pip \
      libldap2-dev \
      libsasl2-dev \
   && apt-get -yq autoremove

# Ensure locale fr_FR.utf8 is present
# (installing build-essential (may) update locale package and removes the fr_FR which is only generated
# in the xivo-db container)
RUN localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8


#Insert data required for running integration tests
WORKDIR /usr/src/xivo-dird

COPY . /usr/src/xivo-dird
RUN sed '/sqlalchemy.url/ s/localhost/:5432/' -i alembic.ini

COPY bin/xivo-dird-init-db /usr/bin/

COPY contribs/docker/zz-initdb.sh /docker-entrypoint-initdb.d/
# Dont redirect stdout in log for test
RUN sed '/exec \&>>/d' -i /usr/local/bin/docker-entrypoint.sh
