<commit_before>FROM alpine:3.10.3

RUN apk update \
    && apk add --no-cache --upgrade\
        augeas \
        augeas-dev \
        bash \
        bison \
        build-base \
        cmake \
        curl \
        git \
        libgit2 \
        libgit2-dev \
        ninja \
        sudo \
        yajl \
        yajl-dev \
        yaml-cpp \
        yaml-cpp-dev


# Google Test (TODO: update before 0.9.2 to gtest 1.10.0, but does not work with elektra 0.9.1)
ENV GTEST_ROOT=/opt/gtest
ARG GTEST_VER=release-1.8.1
RUN mkdir -p ${GTEST_ROOT} \
    && cd /tmp \
    && curl -o gtest.tar.gz \
      -L https://github.com/google/googletest/archive/${GTEST_VER}.tar.gz \
    && tar -zxvf gtest.tar.gz --strip-components=1 -C ${GTEST_ROOT} \
    && rm gtest.tar.gz

ENV ELEKTRA_ROOT=/opt/elektra
ENV ELEKTRA_RELEASE=0.9.1
RUN mkdir -p ${ELEKTRA_ROOT} \
    && cd /tmp \
    && curl -o elektra.tar.gz \
      -L https://www.libelektra.org/ftp/elektra/releases/elektra-${ELEKTRA_RELEASE}.tar.gz \
    && tar -zxvf elektra.tar.gz --strip-components=1 -C ${ELEKTRA_ROOT} \
    && rm elektra.tar.gz

# PATCH YAML ENDLINE (TODO: remove this)
RUN sed -i '536s/output << data;/output << data << endl;/' ${ELEKTRA_ROOT}/src/plugins/yamlcpp/write.cpp

ARG USERID=1000
RUN adduser -u ${USERID} -G wheel -D elektra

ARG PARALLEL=8
WORKDIR ${ELEKTRA_ROOT}
RUN mkdir build \
    && cd build \
    && cmake -DPLUGINS="ALL;-date" \
             -DTOOLS="ALL" \
             -DENABLE_DEBUG="OFF" \
             -DENABLE_LOGGER="OFF" \
             -DCMAKE_BUILD_TYPE="Release" \
             -DKDB_DB_SYSTEM='/home/elektra/.config/kdb/system' \
             -DKDB_DB_SPEC='/home/elektra/.config/kdb/spec' \
             -DKDB_DB_HOME='/home/elektra/.config/kdb/home' \
             .. \
    && make -j ${PARALLEL} \
    && ctest -T Test --output-on-failure -j ${PARALLEL} \
    && kdb cache clear \
    && rm -Rf '/home/elektra/.config' '/home/elektra/.cache' \
    && cmake -DBUILD_TESTING=OFF -UKDB_DB_SYSTEM -UKDB_DB_SPEC -UKDB_DB_HOME . \
    && make -j ${PARALLEL} \
    && rm -Rf ${GTEST_ROOT}


FROM alpine:3.10.3
COPY --from=0 ${ELEKTRA_ROOT} \
              ${ELEKTRA_ROOT}
ARG USERID=1000

ENV ELEKTRA_ROOT=/opt/elektra
WORKDIR ${ELEKTRA_ROOT}
RUN cd build \
    && make install \
    && ldconfig /usr/local/lib/elektra/ \
    && rm -Rf ${ELEKTRA_ROOT} \
    && rm -Rf ${GTEST_ROOT}

RUN apk del \
        augeas-dev \
        bison \
        build-base \
        cmake \
        git \<commit_msg>docker: alpine release image clear cache<commit_after>FROM alpine:3.10.3

RUN apk update \
    && apk add --no-cache --upgrade\
        augeas \
        augeas-dev \
        bash \
        bison \
        build-base \
        cmake \
        curl \
        git \
        libgit2 \
        libgit2-dev \
        ninja \
        sudo \
        yajl \
        yajl-dev \
        yaml-cpp \
        yaml-cpp-dev


# Google Test (TODO: update before 0.9.2 to gtest 1.10.0, but does not work with elektra 0.9.1)
ENV GTEST_ROOT=/opt/gtest
ARG GTEST_VER=release-1.8.1
RUN mkdir -p ${GTEST_ROOT} \
    && cd /tmp \
    && curl -o gtest.tar.gz \
      -L https://github.com/google/googletest/archive/${GTEST_VER}.tar.gz \
    && tar -zxvf gtest.tar.gz --strip-components=1 -C ${GTEST_ROOT} \
    && rm gtest.tar.gz

ENV ELEKTRA_ROOT=/opt/elektra
ENV ELEKTRA_RELEASE=0.9.1
RUN mkdir -p ${ELEKTRA_ROOT} \
    && cd /tmp \
    && curl -o elektra.tar.gz \
      -L https://www.libelektra.org/ftp/elektra/releases/elektra-${ELEKTRA_RELEASE}.tar.gz \
    && tar -zxvf elektra.tar.gz --strip-components=1 -C ${ELEKTRA_ROOT} \
    && rm elektra.tar.gz

# PATCH YAML ENDLINE (TODO: remove this)
RUN sed -i '536s/output << data;/output << data << endl;/' ${ELEKTRA_ROOT}/src/plugins/yamlcpp/write.cpp

ARG USERID=1000
RUN adduser -u ${USERID} -G wheel -D elektra

ARG PARALLEL=8
WORKDIR ${ELEKTRA_ROOT}
RUN mkdir build \
    && cd build \
    && cmake -DPLUGINS="ALL;-date" \
             -DTOOLS="ALL" \
             -DENABLE_DEBUG="OFF" \
             -DENABLE_LOGGER="OFF" \
             -DCMAKE_BUILD_TYPE="Release" \
             -DKDB_DB_SYSTEM='/home/elektra/.config/kdb/system' \
             -DKDB_DB_SPEC='/home/elektra/.config/kdb/spec' \
             -DKDB_DB_HOME='/home/elektra/.config/kdb/home' \
             .. \
    && make -j ${PARALLEL} \
    && ctest -T Test --output-on-failure -j ${PARALLEL} \
    && ./bin/kdb cache clear \
    && rm -Rf '/home/elektra/.config' '/home/elektra/.cache' \
    && cmake -DBUILD_TESTING=OFF -UKDB_DB_SYSTEM -UKDB_DB_SPEC -UKDB_DB_HOME . \
    && make -j ${PARALLEL} \
    && rm -Rf ${GTEST_ROOT}


FROM alpine:3.10.3
COPY --from=0 ${ELEKTRA_ROOT} \
              ${ELEKTRA_ROOT}
ARG USERID=1000

ENV ELEKTRA_ROOT=/opt/elektra
WORKDIR ${ELEKTRA_ROOT}
RUN cd build \
    && make install \
    && ldconfig /usr/local/lib/elektra/ \
    && rm -Rf ${ELEKTRA_ROOT} \
    && rm -Rf ${GTEST_ROOT}

RUN apk del \
        augeas-dev \
        bison \
        build-base \
        cmake \
        git \
{'fraction_non_alphanumeric': 0.15154536390827517, 'fraction_numerical': 0.016350947158524427, 'mean_word_length': 1.8322981366459627, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1451130', 'n_tokens_mistral': 2067, 'n_tokens_neox': 1965, 'n_words': 383}