基于dockerfile构建centos8-ruby-3.2
Ruby是一种高级的、解释型的编程语言,以其清晰的语法和易于理解的代码而闻名
env
- centos8
- ruby3.2
- docker-24.05
安装指导文档
1.download
- https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.5.tar.gz
- https://pyyaml.org/download/libyaml/yaml-0.1.7.tar.gz
2.build image
2.1dockerfile
add压缩文件,会自动解压到目标目录。使用分阶段构建,编译后提取成果到最终镜像中
|
|
2.2构建文件清单及构建过程
├── Dockerfile
├── ruby-3.2.5.tar.gz
└── yaml-0.1.7.tar.gz
docker build -t centos8:ruby-3.2 .
....
installing bundled gem cache: /usr/local/ruby/lib/ruby/gems/3.2.0/cache
ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x86_64-linux]
3.4.19
https://rubygems.org/ removed from sources
https://mirrors.aliyun.com/rubygems/ added to sources
/opt
Removing intermediate container 785198bbb495
---> f6aa2b129d31
Step 8/11 : RUN rm -rf /opt/* && dnf clean all
---> Running in e0113a5ed921
28 files removed
Removing intermediate container e0113a5ed921
---> 1d0de61023c1
Step 9/11 : FROM centos:centos8.4.2105
---> 5d0da3dc9764
Step 10/11 : COPY --from=builder /usr/local/ /usr/local/
---> 278d47620c20
Step 11/11 : RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/yaml.conf && echo "/usr/local/ruby/lib" > /etc/ld.so.conf.d/ruby.conf && ldconfig && echo 'export PATH=/usr/local/ruby/bin:$PATH' > /etc/profile.d/ruby.sh && source /etc/profile && ruby -v && gem -v && gem sources --remove https://rubygems.org/ && gem sources -a https://mirrors.aliyun.com/rubygems/
---> Running in 16fe508c8904
ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x86_64-linux]
3.4.19
https://rubygems.org/ removed from sources
https://mirrors.aliyun.com/rubygems/ added to sources
Removing intermediate container 16fe508c8904
---> 97a8a6648dbf
Successfully built 97a8a6648dbf
Successfully tagged centos8:ruby-3.2
[root@centos8-51 centos8-ruby]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos8 ruby-3.2 97a8a6648dbf 11 minutes ago 464MB
3.测试安装
docker run --rm -it centos8:ruby-3.2 bash
# 安装fpm
gem install fpm
# 查看fpm版本
[root@b7a190dd24b7 /]#
[root@b7a190dd24b7 /]# fpm --version
1.15.1