FROM alpine:latest AS builder

ENV MKDOCS_VERSION=1.1.0 \
    DOCS_DIRECTORY='/mkdocs' \
    LIVE_RELOAD_SUPPORT='false' \
    ADD_MODULES='false' \
    FAST_MODE='false' \
    PYTHONUNBUFFERED=1 \
    GIT_REPO='false' \
    GIT_BRANCH='master' \
    AUTO_UPDATE='false' \
    UPDATE_INTERVAL=15

ADD docker/container-files/ /
ADD mkdocs/requirements.txt  /mkdocs/requirements.txt
RUN \
    apk add --update \
        ca-certificates \
        bash \
        git \
        openssh \
        python3 \
        python3-dev \
        py3-setuptools \
        py-pip \
        build-base \
        libffi-dev cairo-dev cairo cairo-tools \
        jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev
RUN \
    pip install --upgrade pip && \
    pip install -r /mkdocs/requirements.txt && \
    cd /bootstrap && pip install -e /bootstrap && \
    rm -rf /tmp/* /var/tmp/* /var/cache/apk/* /var/cache/distfiles/* && \
    chmod 600 /root/.ssh/config

CMD ["/usr/bin/bootstrap", "start"]

FROM builder as makestatic
ADD docs /src/docs/
ADD mkdocs.yml /src/ 
RUN cd /src  && mkdocs build

FROM nginx
# RUN rm /etc/nginx/sites-enabled/default
COPY docker/default.conf /etc/nginx/conf.d/default.conf
COPY --from=makestatic /src/site /sites/app.lexema.ru/docs