FROM python as python

RUN apt-get update && apt-get install -y  \
    sudo \
    bash \
    build-essential \
    && apt clean && rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade pip && \
    pip install --no-cache-dir Sphinx~=8.2.3 sphinx-immaterial myst-parser sphinxcontrib-images sphinx-notfound-page git+https://github.com/OpenDataServices/sphinxcontrib-redoc.git

WORKDIR /app
COPY app /app

#WORKDIR /app/scripts
#RUN go run generator-admin-guide.go -yaml api_routes.yaml -template admin-guide.tpl > index.rst
#RUN mv index.rst /app/source/admin-guide

#WORKDIR /app/scripts/admin-guide
#RUN go run generator-routes.go ../api_routes.yaml
#COPY 

#WORKDIR /app
RUN sphinx-build -M html ./source ./build

FROM python as app

RUN apt-get update && apt-get install --yes --no-install-recommends \
    gettext \
    nginx \
    && apt-get clean && rm -rf /var/lib/apt/lists/* \
    && service nginx stop \
    && rm \
    /etc/nginx/nginx.conf \
    /etc/nginx/sites-available/* \
    /etc/nginx/sites-enabled/*

COPY ci/nginx/nginx.conf /etc/nginx/nginx.conf

CMD ["bash", "-c", "nginx"]
EXPOSE 8080

