Skip to content

Commit

Permalink
use python as build base
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoQuote committed Nov 16, 2023
1 parent 17755ce commit 63f2a8b
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 77 deletions.
85 changes: 8 additions & 77 deletions src/docker/Dockerfile-base
Original file line number Diff line number Diff line change
@@ -1,86 +1,17 @@
FROM library/almalinux:9 AS compbasedeps
ARG PYTHON_BASE_IMAGE=library/python:3.11-bullseye
FROM ${PYTHON_BASE_IMAGE}

ENV PYTHON_VERSION 3.11.6
ENV DOCKERIZE_VERSION v0.6.1
ENV SOAR_VERSION 0.11.0

ARG HTTPS_PROXY=""
ARG HTTP_PROXY=""
WORKDIR /opt

RUN yum install -y epel-release \
&& yum -y install cmake glibc-common bison gcc-c++ git libaio-devel glib2 glib2-devel libffi-devel gcc make \
zlib-devel openssl openssl-devel ncurses-devel openldap-devel gettext bzip2-devel xz-devel wget diffutils\
#python 3
&& 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 \
&& /usr/local/python3/bin/pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple virtualenv \
#dockerize
&& wget -q https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /opt -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
#sqladvisor
&& yum -yq install https://mirrors.ustc.edu.cn/percona/percona/yum/percona-release-latest.noarch.rpm \
&& yum -yq install Percona-Server-devel-57 Percona-Server-shared-57 Percona-Server-client-57 percona-toolkit \
&& ln -fs /usr/lib64/mysql/libmysqlclient.so.18 /usr/lib64/libperconaserverclient_r.so \
&& cd /opt \
&& curl -o sqladvisor -L https://github.com/LeoQuote/SQLAdvisor/releases/download/v2.1/sqladvisor-linux-amd64 \
&& curl -o sqlparser.tar.gz -L https://github.com/LeoQuote/SQLAdvisor/releases/download/v2.1/sqlparser-linux-amd64.tar.gz \
&& tar -xzvf sqlparser.tar.gz \
#soar
&& cd /opt \
&& wget -q https://github.com/XiaoMi/soar/releases/download/$SOAR_VERSION/soar.linux-amd64 -O soar \
#my2sql
&& wget -q https://raw.githubusercontent.com/liuhr/my2sql/master/releases/centOS_release_7.x/my2sql -O my2sql \
#mongo
&& wget -q -c https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.20.tgz \
&& tar -xvf mongodb-linux-x86_64-rhel70-3.6.20.tgz

FROM library/almalinux:9

ENV TZ=Asia/Shanghai

WORKDIR /opt

COPY --from=compbasedeps /etc/yum.repos.d/epel*.repo /etc/yum.repos.d/
COPY --from=compbasedeps /opt/sqladvisor /opt/
COPY --from=compbasedeps /opt/soar /opt/
COPY --from=compbasedeps /opt/my2sql /opt/
COPY --from=compbasedeps /opt/dockerize /usr/local/bin/
COPY --from=compbasedeps /opt/mongodb-linux-x86_64-rhel70-3.6.20/bin/mongo /usr/local/bin/
COPY --from=compbasedeps /usr/local/python3 /usr/local/python3
COPY --from=compbasedeps /opt/sqlparser /usr/local/sqlparser

RUN yum -yq install glibc-common cyrus-sasl-gssapi cyrus-sasl-plain cmake bison gcc-c++ libaio-devel glib2 \
glib2-devel xz-libs libffi-devel gcc make zlib-devel openssl-devel ncurses-devel openldap-devel gettext \
bzip2-devel xz-devel wget \
#msodbc
&& curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo \
&& ACCEPT_EULA=Y yum -y install msodbcsql17 unixODBC-devel \
#oracle client
&& yum -yq 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 \
# mysql/percona client
&& yum -yq install https://repo.percona.com/yum/percona-release-latest.noarch.rpm \
&& percona-release setup -y ps-57 \
&& yum -yq install Percona-Server-devel-57 Percona-Server-shared-57 Percona-Server-client-57 \
&& percona-release setup -y ps-80 \
&& yum -yq install percona-toolkit \
&& yum -yq remove cmake gcc-c++ libaio-devel \
glib2-devel libffi-devel gcc make gettext \
bzip2-devel wget \
&& yum clean all \
&& rm -rf /var/cache/yum/* \
&& ln -fs /usr/lib64/mysql/libmysqlclient.so.18 /usr/lib64/libperconaserverclient_r.so \
&& ln -fs /usr/lib64/liblzma.so.0 /usr/lib64/liblzma.so \
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& chmod +x sqladvisor soar my2sql \
&& chmod +x /usr/local/bin/dockerize \
&& chmod +x /usr/local/bin/mongo \
&& ln -fs /usr/local/python3/bin/python3 /usr/bin/python3 \
&& ln -fs /usr/local/python3/bin/pip3 /usr/bin/pip3 \
&& ln -fs /usr/local/python3/bin/virtualenv /usr/bin/virtualenv \
&& virtualenv venv4archery --python=python3
COPY src/docker/setup.sh /opt/setup.sh
RUN chmod +x /opt/setup.sh \
&& /opt/setup.sh \
&& rm -rf /opt/setup.sh

ENV LANG zh_CN.UTF-8
ENV LC_ALL zh_CN.UTF-8
51 changes: 51 additions & 0 deletions src/docker/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -euxo pipefail
curl -q -L -o dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
tar -C /opt -xzvf dockerize-alpine-linux-amd64-$DOCKERIZE_VERSION.tar.gz
chmod +x /opt/dockerize
mv /opt/dockerize /usr/local/bin/
#sqladvisor
curl -o sqladvisor -L https://github.com/LeoQuote/SQLAdvisor/releases/download/v2.1/sqladvisor-linux-amd64
chmod +x sqladvisor
curl -o sqlparser.tar.gz -L https://github.com/LeoQuote/SQLAdvisor/releases/download/v2.1/sqlparser-linux-amd64.tar.gz
tar -xzvf sqlparser.tar.gz
mv sqlparser /usr/local/sqlparser
#soar
curl -L -q https://github.com/XiaoMi/soar/releases/download/$SOAR_VERSION/soar.linux-amd64 -o soar
chmod +x soar
#my2sql
curl -L -q https://raw.githubusercontent.com/liuhr/my2sql/master/releases/centOS_release_7.x/my2sql -o my2sql
chmod +x my2sql
#mongo
curl -L -q -o mongodb-linux-x86_64-rhel70-3.6.20.tgz https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.20.tgz
tar -xvf mongodb-linux-x86_64-rhel70-3.6.20.tgz
mv /opt/mongodb-linux-x86_64-rhel70-3.6.20/bin/mongo /usr/local/bin/
chmod +x /usr/local/bin/mongo
rm -rf /opt/mongodb-linux-x86_64-rhel70-3.6.20
#msodbc
curl -q -L https://packages.microsoft.com/keys/microsoft.asc -o /etc/apt/trusted.gpg.d/microsoft.asc
curl -q -L https://packages.microsoft.com/config/debian/11/prod.list -o /etc/apt/sources.list.d/mssql-release.list
apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql18 unixodbc-dev
#oracle client
mkdir -p /opt/oracle
cd /opt/oracle
curl -q -L -o oracle-install.zip https://download.oracle.com/otn_software/linux/instantclient/1921000/instantclient-basic-linux.x64-19.21.0.0.0dbru.zip
unzip oracle-install.zip
apt-get install libaio1
sh -c "echo /opt/oracle/instantclient_19_21 > /etc/ld.so.conf.d/oracle-instantclient.conf"
ldconfig
rm -rf oracle-install.zip
cd -
# mysql/percona client
curl -O https://repo.percona.com/apt/percona-release_latest.generic_all.deb
apt-get install -yq gnupg2 lsb-release ./percona-release_latest.generic_all.deb
apt-get update
percona-release setup -y ps-57
apt-get install -yq percona-toolkit libperconaserverclient20-dev libperconaserverclient20
apt-get install -yq build-essentials
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
echo $TZ > /etc/timezone
chmod +x sqladvisor soar my2sql
chmod +x /usr/local/bin/dockerize
chmod +x /usr/local/bin/mongo
python3 -m venv venv4archery

0 comments on commit 63f2a8b

Please sign in to comment.