<commit_before><%
image = case platform
  when /x86_64-linux/ then "quay.io/pypa/manylinux2014_x86_64"
  when /x86-linux/ then "quay.io/pypa/manylinux2014_i686"
  else "ubuntu:20.04"
end
manylinux = !!(image =~ /manylinux/)
%>
FROM <%= image %>

<% if manylinux %>
# install packages which rvm will require
RUN yum install -y autoconf gcc-c++ libtool readline-devel sqlite-devel ruby openssl-devel xz cmake sudo less libffi-devel git wget

# Prepare sudo and delete sudo as alias to gosu
RUN rm -f /usr/local/bin/sudo && \
    groupadd -r sudo && \
    echo "%sudo  ALL=(ALL)       ALL" >> /etc/sudoers
<% else %>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update && \
    apt-get install -y curl git-core xz-utils build-essential zlib1g-dev libreadline-dev libssl-dev wget unzip sudo gnupg2 dirmngr cmake pkg-config && \
    rm -rf /var/lib/apt/lists/*
<% end %>

# Add "rvm" as system group, to avoid conflicts with host GIDs typically starting with 1000
RUN groupadd -r rvm && useradd -r -g rvm -G sudo -p "" --create-home rvm

# Make sure rvm and later settings are available in interactive and non-interactive shells
RUN echo "source /etc/profile.d/rvm.sh" >> /etc/rubybashrc && \
    echo "source /etc/rubybashrc" >> /etc/bashrc && \
    echo "source /etc/rubybashrc" >> /etc/bash.bashrc
ENV BASH_ENV /etc/rubybashrc

USER rvm

RUN mkdir ~/.gnupg && \
    chmod 700 ~/.gnupg && \
    echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf

# install rvm, RVM 1.26.0+ has signed releases, source rvm for usage outside of package scripts
RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
    (curl -L http://get.rvm.io | sudo bash) && \
    bash -c " \
        source /etc/rubybashrc && \
        rvm autolibs disable && \
        rvmsudo rvm cleanup all "

# Import patch files for ruby and gems
COPY build/patches /home/rvm/patches/

# install rubies and fix permissions on
ENV RVM_RUBIES 2.5.9 3.1.0
RUN bash -c " \
    export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
    for v in ${RVM_RUBIES} ; do \
        rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
    done && \
    rvm cleanup all && \
    find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "

# Install rake-compiler and typical gems in all Rubies
# do not generate documentation for gems
RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
    bash -c " \
        rvm all do gem update --system --no-document && \
        rvm all do gem install --no-document bundler 'bundler:~>1.16' 'rake-compiler:1.1.6' hoe mini_portile rubygems-tasks mini_portile2 && \
        find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "

# Install rake-compiler's cross rubies in global dir instead of /root
RUN sudo mkdir -p /usr/local/rake-compiler && \
    sudo chown rvm.rvm /usr/local/rake-compiler && \
    ln -s /usr/local/rake-compiler ~/.rake-compiler

# Add cross compilers for Windows and Linux
USER root

<% if platform=~/x64-mingw-ucrt/ %>
COPY --from=larskanis/mingw64-ucrt:20.04 /build/*.deb /debs/
RUN dpkg -i /debs/binutils-mingw-w64-x86-64_2.34-6ubuntu1.3+8.8_amd64.deb \
    /debs/g++-mingw-w64-x86-64_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
    /debs/gcc-mingw-w64-base_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
    /debs/gcc-mingw-w64-x86-64_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
    /debs/mingw-w64-common_7.0.0-2_all.deb \
    /debs/mingw-w64-x86-64-dev_7.0.0-2_all.deb

<% elsif !manylinux %>
RUN apt-get -y update && \<commit_msg>Select necessary packages while copying<commit_after><%
image = case platform
  when /x86_64-linux/ then "quay.io/pypa/manylinux2014_x86_64"
  when /x86-linux/ then "quay.io/pypa/manylinux2014_i686"
  else "ubuntu:20.04"
end
manylinux = !!(image =~ /manylinux/)
%>
FROM <%= image %>

<% if manylinux %>
# install packages which rvm will require
RUN yum install -y autoconf gcc-c++ libtool readline-devel sqlite-devel ruby openssl-devel xz cmake sudo less libffi-devel git wget

# Prepare sudo and delete sudo as alias to gosu
RUN rm -f /usr/local/bin/sudo && \
    groupadd -r sudo && \
    echo "%sudo  ALL=(ALL)       ALL" >> /etc/sudoers
<% else %>
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update && \
    apt-get install -y curl git-core xz-utils build-essential zlib1g-dev libreadline-dev libssl-dev wget unzip sudo gnupg2 dirmngr cmake pkg-config && \
    rm -rf /var/lib/apt/lists/*
<% end %>

# Add "rvm" as system group, to avoid conflicts with host GIDs typically starting with 1000
RUN groupadd -r rvm && useradd -r -g rvm -G sudo -p "" --create-home rvm

# Make sure rvm and later settings are available in interactive and non-interactive shells
RUN echo "source /etc/profile.d/rvm.sh" >> /etc/rubybashrc && \
    echo "source /etc/rubybashrc" >> /etc/bashrc && \
    echo "source /etc/rubybashrc" >> /etc/bash.bashrc
ENV BASH_ENV /etc/rubybashrc

USER rvm

RUN mkdir ~/.gnupg && \
    chmod 700 ~/.gnupg && \
    echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf

# install rvm, RVM 1.26.0+ has signed releases, source rvm for usage outside of package scripts
RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
    (curl -L http://get.rvm.io | sudo bash) && \
    bash -c " \
        source /etc/rubybashrc && \
        rvm autolibs disable && \
        rvmsudo rvm cleanup all "

# Import patch files for ruby and gems
COPY build/patches /home/rvm/patches/

# install rubies and fix permissions on
ENV RVM_RUBIES 2.5.9 3.1.0
RUN bash -c " \
    export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
    for v in ${RVM_RUBIES} ; do \
        rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
    done && \
    rvm cleanup all && \
    find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "

# Install rake-compiler and typical gems in all Rubies
# do not generate documentation for gems
RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
    bash -c " \
        rvm all do gem update --system --no-document && \
        rvm all do gem install --no-document bundler 'bundler:~>1.16' 'rake-compiler:1.1.6' hoe mini_portile rubygems-tasks mini_portile2 && \
        find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "

# Install rake-compiler's cross rubies in global dir instead of /root
RUN sudo mkdir -p /usr/local/rake-compiler && \
    sudo chown rvm.rvm /usr/local/rake-compiler && \
    ln -s /usr/local/rake-compiler ~/.rake-compiler

# Add cross compilers for Windows and Linux
USER root

<% if platform=~/x64-mingw-ucrt/ %>
COPY --from=larskanis/mingw64-ucrt:20.04 \
    /build/binutils-mingw-w64-x86-64_2.34-6ubuntu1.3+8.8_amd64.deb \
    /build/g++-mingw-w64-x86-64_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
    /build/gcc-mingw-w64-base_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
    /build/gcc-mingw-w64-x86-64_9.3.0-17ubuntu1~20.04+22~exp1ubuntu4_amd64.deb \
    /build/mingw-w64-common_7.0.0-2_all.deb \
    /build/mingw-w64-x86-64-dev_7.0.0-2_all.deb \
    /debs/
RUN dpkg -i /debs/*.deb

<% elsif !manylinux %>
RUN apt-get -y update && \
{'fraction_non_alphanumeric': 0.13941839432308334, 'fraction_numerical': 0.05955196883261444, 'mean_word_length': 2.845906902086677, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6155399', 'n_tokens_mistral': 3143, 'n_tokens_neox': 2784, 'n_words': 726}