|
| 1 | +#-------------------------------------------------------------------------------------------------- |
| 2 | +# This dockerfile builds the unified image for running Scalyr agent unit & smoke tests |
| 3 | +# |
| 4 | +# It requires the following files: |
| 5 | +# |
| 6 | +# smoketest |
| 7 | +# override_files |
| 8 | +# agent.json (agent config file with placeholder serverHost token) |
| 9 | +# smoketest.py (main smoketest python script) |
| 10 | +# unittest |
| 11 | +# unittest.sh (unittest script) |
| 12 | +#-------------------------------------------------------------------------------------------------- |
| 13 | + |
| 14 | +FROM centos |
| 15 | + |
| 16 | +RUN yum install -y sudo gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel which wget |
| 17 | +RUN yum install -y libffi-devel |
| 18 | +RUN yum install -y ruby-devel gcc make rpm-build rubygems # fpm needed for building rpm |
| 19 | +RUN yum install -y initscripts |
| 20 | +# Install fpm globally |
| 21 | +RUN gem install --no-user-install --no-ri --no-rdoc fpm |
| 22 | +RUN yum -y install net-tools |
| 23 | +RUN yum install -y epel-release && yum install -y python36 python36-pip |
| 24 | +RUN pip3 install requests |
| 25 | + |
| 26 | +RUN useradd -ms /bin/bash scalyr \ |
| 27 | +&& echo "scalyr:scalyr" | chpasswd \ |
| 28 | +&& usermod -aG wheel scalyr \ |
| 29 | +&& echo "scalyr ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers |
| 30 | + |
| 31 | +# Install pyenv versions |
| 32 | + |
| 33 | +RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv \ |
| 34 | +&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc \ |
| 35 | +&& echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \ |
| 36 | +&& echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc |
| 37 | + |
| 38 | +RUN source ~/.bashrc && pyenv install 3.7.3 |
| 39 | +RUN source ~/.bashrc && pyenv install 2.7.12 |
| 40 | +RUN source ~/.bashrc && pyenv install 2.6.9 |
| 41 | +RUN source ~/.bashrc && pyenv install 2.5.4 |
| 42 | +RUN source ~/.bashrc && pyenv install 2.4.1 |
| 43 | + |
| 44 | +RUN source ~/.bashrc && pyenv shell 3.7.3 && pip3 install requests |
| 45 | +RUN source ~/.bashrc && pyenv shell 2.7.12 && pip install ujson mock |
| 46 | +RUN source ~/.bashrc && pyenv shell 2.6.9 && pip install ujson mock |
| 47 | + |
| 48 | +# Python 2.5 and below requires libssl.so which we need to build |
| 49 | +# Also cannot install mock library with pip as it keeps upgrading to incompatible version |
| 50 | +# Instead download source and build |
| 51 | +RUN source ~/.bashrc && pyenv shell 2.5.4 \ |
| 52 | +&& pushd /tmp \ |
| 53 | +&& wget https://files.pythonhosted.org/packages/83/21/f469c9923235f8c36d5fd5334ed11e2681abad7e0032c5aba964dcaf9bbb/ssl-1.16.tar.gz \ |
| 54 | +&& tar zxvf ssl-1.16.tar.gz \ |
| 55 | +&& cd ssl-1.16 \ |
| 56 | +&& sudo ln -s /usr/lib64/libssl.so /usr/lib \ |
| 57 | +&& make && make install \ |
| 58 | +&& popd \ |
| 59 | +&& pip install ujson \ |
| 60 | +&& pushd /tmp && wget https://files.pythonhosted.org/packages/52/22/05f0fb67c51e86b485914b1da519b2df6afd36c41f81a21328bc69a2e3b1/mock-0.8.0.tar.gz \ |
| 61 | +&& tar zxf mock-0.8.0.tar.gz && cd mock-0.8.0 && python setup.py build && python setup.py install |
| 62 | + |
| 63 | +# Install Python 2.4 packages |
| 64 | +RUN source ~/.bashrc && pyenv shell 2.4.1 \ |
| 65 | +&& pip install --index-url=https://pypi.python.org/simple/ ujson \ |
| 66 | +&& pushd /tmp/mock-0.8.0 && python setup.py build && python setup.py install |
| 67 | + |
| 68 | +#------------------------------------------------------ |
| 69 | +# Copy pyenv to scalyr user |
| 70 | +#------------------------------------------------------ |
| 71 | +# RUN sudo cp ~scalyr/.bashrc /root/.bashrc |
| 72 | +# RUN sudo ln -s ~scalyr/.pyenv /root/.pyenv |
| 73 | +# RUN gem install --no-ri --no-rdoc fpm |
| 74 | + |
| 75 | +USER scalyr |
| 76 | +WORKDIR /home/scalyr |
| 77 | + |
| 78 | +RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv \ |
| 79 | +&& echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc \ |
| 80 | +&& echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc \ |
| 81 | +&& echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc |
| 82 | + |
| 83 | +RUN source ~/.bashrc && pyenv install 3.7.3 |
| 84 | +RUN source ~/.bashrc && pyenv install 2.7.12 |
| 85 | +RUN source ~/.bashrc && pyenv install 2.6.9 |
| 86 | +RUN source ~/.bashrc && pyenv install 2.5.4 |
| 87 | +RUN source ~/.bashrc && pyenv install 2.4.1 |
| 88 | + |
| 89 | +RUN source ~/.bashrc && pyenv shell 3.7.3 && pip3 install requests |
| 90 | +RUN source ~/.bashrc && pyenv shell 2.7.12 && pip install ujson mock |
| 91 | +RUN source ~/.bashrc && pyenv shell 2.6.9 && pip install ujson mock |
| 92 | + |
| 93 | +# Python 2.5 and below requires libssl.so which we need to build |
| 94 | +# Also cannot install mock library with pip as it keeps upgrading to incompatible version |
| 95 | +# Instead download source and build |
| 96 | +RUN sudo rm -rf /tmp/ssl-1.16 |
| 97 | +RUN sudo rm -rf /tmp/mock-0.8.0 |
| 98 | + |
| 99 | +# Install Python 2.5 packages AND fix mock library install locations (otherwise unittest-25 fails) |
| 100 | +RUN source ~/.bashrc && pyenv shell 2.5.4 \ |
| 101 | +&& pushd /tmp \ |
| 102 | +&& wget https://files.pythonhosted.org/packages/83/21/f469c9923235f8c36d5fd5334ed11e2681abad7e0032c5aba964dcaf9bbb/ssl-1.16.tar.gz \ |
| 103 | +&& tar zxvf ssl-1.16.tar.gz \ |
| 104 | +&& cd ssl-1.16 \ |
| 105 | +&& sudo ln -sf /usr/lib64/libssl.so /usr/lib \ |
| 106 | +&& make && make install \ |
| 107 | +&& popd \ |
| 108 | +&& pip install ujson \ |
| 109 | +&& pushd /tmp && wget https://files.pythonhosted.org/packages/52/22/05f0fb67c51e86b485914b1da519b2df6afd36c41f81a21328bc69a2e3b1/mock-0.8.0.tar.gz \ |
| 110 | +&& tar zxf mock-0.8.0.tar.gz && cd mock-0.8.0 && python setup.py build && sudo python setup.py install --prefix=/home/scalyr/.pyenv/versions/2.5.4 \ |
| 111 | +&& sudo chown -R scalyr:scalyr /home/scalyr/.pyenv/versions/2.5.4/lib/python2.7 \ |
| 112 | +&& mv /home/scalyr/.pyenv/versions/2.5.4/lib/python2.7/site-packages/* /home/scalyr/.pyenv/versions/2.5.4/lib/python2.5/site-packages |
| 113 | + |
| 114 | +# Install Python 2.4 packages AND fix mock library install locations (otherwise unittest-24 fails) |
| 115 | +RUN source ~/.bashrc && pyenv shell 2.4.1 \ |
| 116 | +&& pip install --index-url=https://pypi.python.org/simple/ ujson \ |
| 117 | +&& pushd /tmp/mock-0.8.0 && sudo python setup.py build && sudo python setup.py install --prefix=/home/scalyr/.pyenv/versions/2.4.1 --prefix=/home/scalyr/.pyenv/versions/2.4.1 \ |
| 118 | +&& sudo chown -R scalyr:scalyr /home/scalyr/.pyenv/versions/2.4.1/lib/python2.7 \ |
| 119 | +&& mv /home/scalyr/.pyenv/versions/2.4.1/lib/python2.7/site-packages/* /home/scalyr/.pyenv/versions/2.4.1/lib/python2.4/site-packages |
| 120 | + |
| 121 | +#------------------------------------------------------ |
| 122 | +# Python 2.6 and 2.7 with non-working ssl |
| 123 | +#------------------------------------------------------ |
| 124 | +RUN source ~/.bashrc && pyenv install 2.6.6 |
| 125 | +RUN source ~/.bashrc && pyenv install 2.7.2 |
| 126 | +RUN mv /home/scalyr/.pyenv/versions/2.6.6/lib/python2.6/ssl.py /home/scalyr/.pyenv/versions/2.6.6/lib/python2.6/ssl_hide.py |
| 127 | +RUN /bin/rm -f /home/scalyr/.pyenv/versions/2.6.6/lib/python2.6/ssl.pyc |
| 128 | +RUN mv /home/scalyr/.pyenv/versions/2.7.2/lib/python2.7/ssl.py /home/scalyr/.pyenv/versions/2.7.2/lib/python2.7/ssl_hide.py |
| 129 | +RUN /bin/rm -f /home/scalyr/.pyenv/versions/2.7.2/lib/python2.7/ssl.pyc |
| 130 | + |
| 131 | +#------------------------------------------------------ |
| 132 | +# Copy and run test scripts |
| 133 | +#------------------------------------------------------ |
| 134 | +COPY unittest smoketest /tmp/ |
| 135 | + |
0 commit comments