Openshift ruby runtime 简介
本文是对下文的翻译:
https://docs.openshift.com/container-platform/3.9/using_images/s2i_images/ruby.html
OpenShift提供了S2I enabled Ruby images去部署和执行Ruby应用。 这个Ruby S2I builder image收集你的application source及其所需要的依赖去创建一个新的image, 以容器化你的Ruby应用。这个最终的image可以在openshift或者Docker上运行。
目前, Openshift提供的Ruby版本有2.0, 2.2和2.3,提供了两种base image, RHEL7 Images和centos 7 Images
获得两个Images的方法是:
$ docker pull registry.access.redhat.com/rhscl/ruby-22-rhel7
$ docker pull openshift/ruby-22-centos7
你可以在import-image为openshift imagestream.
编译的过程
S2I通过注入source code然后让这个container准备source code却执行而产出ready-to-run images。只要的步骤有以下几步:
1. 从builder image中起一个container
2. 下载application source
3. streams 脚本和sources 到build image container
4. 运行assemble script
5. 保存the final image
Ruby image提供了一些环境便令去让我们控制这些Ruby runtime的行为
去配置这些环境变量,你可以将他们放置在 .sti/environment或者在BuildConfig的environment section定义。
让我们简单看一下有那些环境变量:
RACK_ENV: 这个变量定义了ruby application是production, development, or test。每种对应不同的行为,例如errors page, ruby gem installations, log levels等。默认值为production.
RAILS_ENV: 大致同上。让二者保持一致即可。默认该值等于${RACK_ENV}
DISABLE_ASSET_COMPILATION: Assect compilcation只会发生在production环境。如果assets已经被编译,则可以使用该变量关掉该功能。
PS: 变量不在此一一说明。
Hot Deploying
Hot deployment允许你可以很快的部署变化而不用重新生成一个S2I build.