Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用 python 镜像替代 centos, 升级 python 到 3.11 #2389

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

LeoQuote
Copy link
Collaborator

@LeoQuote LeoQuote commented Nov 16, 2023

  1. 3.11 有很大的性能提升
  2. centos 凉了, 现在这个版本已经不能升了, 而最新的 urllib3 需要升 openssl
  3. 不怎么会 centos, 就直接换了 base
  4. 原镜像自己build python,调试很费时间

现在的问题:

  1. 镜像有些大, 现在有 2G
docker pull ghcr.io/leoquote/archery   
docker pull ghcr.io/leoquote/archery-base

可以试用

Copy link

codecov bot commented Nov 16, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7f5e9bd) 76.28% compared to head (afbd1e6) 76.28%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2389   +/-   ##
=======================================
  Coverage   76.28%   76.28%           
=======================================
  Files         114      114           
  Lines       15800    15800           
=======================================
  Hits        12053    12053           
  Misses       3747     3747           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LeoQuote LeoQuote changed the title 用 almalinux 替代 centos, 升级 python 到 3.11 用 python 镜像替代 centos, 升级 python 到 3.11 Nov 17, 2023
@LeoQuote LeoQuote mentioned this pull request Nov 17, 2023
@hhyo
Copy link
Owner

hhyo commented Nov 18, 2023

涨的有点多,建议先看看继续基于centos是否有解,当然也可以提供多版本镜像,通过tag区分

dockerize这个组件好像也可以废弃了

@LeoQuote
Copy link
Collaborator Author

重新比较了下, 这个是 docker images 的结果, 比较统一一点, 实际大小是要比之前大 300M (20%)的.

REPOSITORY                 TAG           IMAGE ID       CREATED         SIZE
archery-base               latest        6401bb3ea704   7 hours ago     1.34GB
ghcr.io/leoquote/archery   latest        3d3efe8c3c7b   29 hours ago    1.94GB
hhyo/archery-base          sha-b3a08ef   001d746f5936   10 months ago   1.07GB
ghcr.io/hhyo/archery       master        23347e485f1b   2 days ago      1.65GB

理论上来说, 想要精简镜像体积, 应该是采取这样的方式:

  1. 将依赖分割开来, 比如比较占空间的, engine driver (oracle, mssql) 等, 可以作为可选, 很多用户其实用不到.
  2. 每次发版以及 master 分支, 提供两种镜像供选择: 基础镜像(仅有mysql driver 等基础功能) , 全功能镜像

另外 centos 换 debian 看你意见怎么样, 这事更多像是风格问题, 我这边出发点主要还是官方提供的 python 镜像是基于 debian 的, 省的编译

@LeoQuote
Copy link
Collaborator Author

│ Layers ├─────────────────────────────────────────────────────────────────────────────────────────── Permission     UID:GID       Size  Filetree                                                           
Cmp   Size  Command                                                                                   drwxr-xr-x         0:0      44 kB  ├─⊕ etc                                                            
    124 MB  FROM 8b0bad44ef0606b                                                                      drwxr-xr-x         0:0     288 MB  ├── opt                                                            
     29 MB  set -eux;     apt-get update;     apt-get install -y --no-install-recommends         ca-c drwxr-xr-x         0:0     2.3 MB  │   ├── microsoft                                                  
    152 MB  apt-get update && apt-get install -y --no-install-recommends         git         mercuria drwxr-xr-x         0:0     2.3 MB  │   │   └── msodbcsql18                                            
    529 MB  set -ex;     apt-get update;     apt-get install -y --no-install-recommends         autoc drwxr-xr-x         0:0      149 B  │   │       ├── etc                                                
     18 MB  RUN /bin/sh -c set -eux;     apt-get update;     apt-get install -y --no-install-recommen -rwxr-xr-x         0:0      149 B  │   │       │   └── odbcinst.ini                                   
     57 MB  RUN /bin/sh -c set -eux;         wget -O python.tar.xz "https://www.python.org/ftp/python drwxr-xr-x         0:0      44 kB  │   │       ├── include                                            
       0 B  RUN /bin/sh -c set -eux;     for src in idle3 pydoc3 python3 python3-config; do         d -rw-r--r--         0:0      44 kB  │   │       │   └── msodbcsql.h                                    
     11 MB  RUN /bin/sh -c set -eux;         wget -O get-pip.py "$PYTHON_GET_PIP_URL";     echo "$PYT drwxr-xr-x         0:0     2.1 MB  │   │       ├── lib64                                              
       0 B  WORKDIR /opt                                                                              -rwxr-xr-x         0:0     2.1 MB  │   │       │   └── libmsodbcsql-18.3.so.2.1                       
    2.7 kB  COPY src/docker/setup.sh /opt/setup.sh # buildkit                                         drwxr-xr-x         0:0     201 kB  │   │       └── share                                              
    419 MB  RUN |2 HTTPS_PROXY= HTTP_PROXY= /bin/sh -c chmod +x /opt/setup.sh     && /opt/setup.sh    drwxr-xr-x         0:0     201 kB  │   │           └── resources                                      
                                                                                                      drwxr-xr-x         0:0     201 kB  │   │               └── en_US                                      
│ Layer Details ├──────────────────────────────────────────────────────────────────────────────────── -rw-r--r--         0:0     201 kB  │   │                   └── msodbcsqlr18.rll                       
                                                                                                      -rwxr-xr-x         0:0     7.9 MB  │   ├── my2sql                                                     
Tags:   (unavailable)                                                                                 drwxr-xr-x         0:0     240 MB  │   ├── oracle                                                     
Id:     d8d340c12404de5472dd245d3cdfdeac194adfc1b3177c87fbf739b9e9aa51e9                              drwxr-xr-x         0:0     240 MB  │   │   └── instantclient_19_21                                    
Digest: sha256:9c33d2e306b3a72a8d20fd1e84e11c6471e30b4233625c28c773b5efb4eac135                       -r-xr-xr-x         0:0     5.8 kB  │   │       ├── BASIC_LICENSE                                      
Command:                                                                                              -rw-r--r--         0:0     1.6 kB  │   │       ├── BASIC_README                                       
RUN |2 HTTPS_PROXY= HTTP_PROXY= /bin/sh -c chmod +x /opt/setup.sh     && /opt/setup.sh     && rm -rf  -rwxr-xr-x         0:0      42 kB  │   │       ├── adrci                                              
/opt/setup.sh # buildkit                                                                              -rwxr-xr-x         0:0      59 kB  │   │       ├── genezi                                             
                                                                                                      -rwxrwxrwx         0:0        0 B  │   │       ├── libclntsh.so → libclntsh.so.19.1                   
                                                                                                      -rwxrwxrwx         0:0        0 B  │   │       ├── libclntsh.so.10.1 → libclntsh.so.19.1              
                                                                                                      -rwxrwxrwx         0:0        0 B  │   │       ├── libclntsh.so.11.1 → libclntsh.so.19.1              
                                                                                                      -rwxrwxrwx         0:0        0 B  │   │       ├── libclntsh.so.12.1 → libclntsh.so.19.1              
                                                                                                      -rwxrwxrwx         0:0        0 B  │   │       ├── libclntsh.so.18.1 → libclntsh.so.19.1              
                                                                                                      -rwxr-xr-x         0:0      82 MB  │   │       ├── libclntsh.so.19.1                                  
│ Image Details ├──────────────────────────────────────────────────────────────────────────────────── -rwxr-xr-x         0:0     8.1 MB  │   │       ├── libclntshcore.so.19.1                              
                                                                                                      -r-xr-xr-x         0:0     3.7 MB  │   │       ├── libipc1.so                                         
Image name: ghcr.io/leoquote/archery:latest                                                           -r-xr-xr-x         0:0     479 kB  │   │       ├── libmql1.so                                         
Total Image size: 1.9 GB                                                                              -rwxr-xr-x         0:0     5.9 MB  │   │       ├── libnnz19.so                                        
Potential wasted space: 41 MB                                                                         -rwxrwxrwx         0:0        0 B  │   │       ├── libocci.so → libocci.so.19.1                       
Image efficiency score: 98 %                                                                          -rwxrwxrwx         0:0        0 B  │   │       ├── libocci.so.10.1 → libocci.so.19.1                  
                                                                                                      -rwxrwxrwx         0:0        0 B  │   │       ├── libocci.so.11.1 → libocci.so.19.1                  
Count   Total Space  Path                                                                             -rwxrwxrwx         0:0        0 B  │   │       ├── libocci.so.12.1 → libocci.so.19.1                  
    2         15 MB  /opt/soar                                                                        -rwxrwxrwx         0:0        0 B  │   │       ├── libocci.so.18.1 → libocci.so.19.1                  
    2        7.9 MB  /opt/my2sql                                                                      -rwxr-xr-x         0:0     2.3 MB  │   │       ├── libocci.so.19.1                                    
    7        6.0 MB  /var/cache/debconf/templates.dat                                                 -rwxr-xr-x         0:0     131 MB  │   │       ├── libociei.so                                        
    6        5.0 MB  /var/cache/debconf/templates.dat-old                                             -r-xr-xr-x         0:0     154 kB  │   │       ├── libocijdbc19.so                                    
    7        1.9 MB  /var/lib/dpkg/status                                                             -rwxr-xr-x         0:0     116 kB  │   │       ├── liboramysql19.so                      

这个是 dive 给的分析报告, 你可以看到 oracle 的 driver 就占了 200M

@hhyo
Copy link
Owner

hhyo commented Nov 18, 2023

那还好,差的不多

基础镜像和完整镜像这个可以考虑,不过基础到什么程度还是比较难界定

换基础系统也没问题,只是测试方面就需要稍微多看看,避免有什么兼容性问题,可以多关注时区、中文命令行的兼容性这块

还有看起来把核心的构建命令单独成了一个shell脚本,会不会导致构建缓存问题

@LeoQuote
Copy link
Collaborator Author

命令行这块我直接把中文命令行砍了, 语言是英文的, 目前我 k8s 已经用上了, 我当前没发现有什么问题, 时区还是沿用之前的上海

构建是脚本还是命令都是一样的, 在空间占用方面没有区别, 弄成脚本就是可读性好点, 测试方便一点.

@LeoQuote LeoQuote requested a review from hhyo November 21, 2023 09:47
@hhyo
Copy link
Owner

hhyo commented Nov 21, 2023

测试一下包含中文字符的SQL语句优化

@LeoQuote
Copy link
Collaborator Author

@hhyo 测试了下, 没问题

图片

@LeoQuote LeoQuote merged commit 1e06868 into hhyo:master Nov 22, 2023
11 checks passed
@LeoQuote LeoQuote deleted the upgrade-base-image branch November 22, 2023 15:28
finovy pushed a commit to finovy/Archery that referenced this pull request Dec 1, 2023
Update Dockerfile-base with Python 3.11-bullseye
and other dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants