FROM docker.io/centos:7

ENV PYTHON_VERSION 3.6.5
ENV DOCKERIZE_VERSION v0.6.1
ENV SOAR_VERSION 0.11.0

ENV TZ=Asia/Shanghai
ENV LANG en_US.UTF-8

WORKDIR /opt

#locale
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
    && yum -y install kde-l10n-Chinese \
    && localedef -c -f UTF-8 -i zh_CN zh_CN.utf8

ENV LC_ALL zh_CN.utf8

#python
RUN yum -y install libffi-devel wget gcc make zlib-devel openssl openssl-devel ncurses-devel openldap-devel gettext \
    && cd /opt \
    && wget "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.xz" \
    && tar -xvJf Python-$PYTHON_VERSION.tar.xz \
    && cd /opt/Python-$PYTHON_VERSION \
    && ./configure prefix=/usr/local/python3 \
    && make && make install \
    && ln -fs /usr/local/python3/bin/python3 /usr/bin/python3 \
    && ln -fs /usr/local/python3/bin/pip3 /usr/bin/pip3 \
    && pip3 install virtualenv \
    && cd /opt \
    && ln -fs /usr/local/python3/bin/virtualenv /usr/bin/virtualenv \
    && virtualenv venv4archery --python=python3 \
    && rm -rf Python-$PYTHON_VERSION \
    && rm -rf Python-$PYTHON_VERSION.tar.xz \
#dockerize
    && wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
    && tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
    && rm dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
#sqladvisor
    && yum -y install epel-release \
    && yum -y install cmake bison gcc-c++ git mysql-devel libaio-devel  glib2 glib2-devel \
    && yum -y install https://repo.percona.com/yum/percona-release-latest.noarch.rpm \
    && yum -y install Percona-Server-devel-56 Percona-Server-shared-56  Percona-Server-client-56 \
    && yum -y install percona-toolkit \
    && cd /opt \
    && git clone https://github.com/hhyo/SQLAdvisor.git --depth 3 \
    && cd /opt/SQLAdvisor/ \
    && cmake -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=/usr/local/sqlparser ./ \
    && make && make install \
    && cd sqladvisor/ \
    && cmake -DCMAKE_BUILD_TYPE=debug ./ \
    && make \
    && mv /opt/SQLAdvisor/sqladvisor/sqladvisor /opt \
    && rm -rf /opt/SQLAdvisor/
#soar
RUN cd /opt \
    && wget https://github.com/XiaoMi/soar/releases/download/$SOAR_VERSION/soar.linux-amd64 -O soar \
    && chmod a+x soar \
#binlog2sql
    && cd /opt \
    && git clone https://github.com/danfengcao/binlog2sql.git \
    && mv binlog2sql/binlog2sql/ tmp_binlog2sql \
    && rm -rf binlog2sql \
#msodbc
    && cd /opt \
    && curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo \
    && ACCEPT_EULA=Y yum -y install msodbcsql17 \
    && yum -y install unixODBC-devel \
#oracle instantclient
    && yum -y install http://yum.oracle.com/repo/OracleLinux/OL7/oracle/instantclient/x86_64/getPackage/oracle-instantclient19.3-basiclite-19.3.0.0.0-1.x86_64.rpm

