首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Openshift 3-覆盖.s2i/bin文件-组装和运行脚本

Openshift 3-覆盖.s2i/bin文件-组装和运行脚本
EN

Stack Overflow用户
提问于 2017-10-17 23:18:35
回答 2查看 1.2K关注 0票数 2

我希望澄清可以添加到项目repo中.s2i/bin目录中的可能脚本。

文档说,当您添加这些文件时,它们将在构建项目时重写相同名称的默认文件()。例如,如果我将自己的“汇编”文件放置在.s2i/bin目录中,默认的汇编文件也会运行,还是会被脚本完全替换?如果我想要默认文件的一些行为怎么办?我是否必须将默认的“组装”内容复制到我的文件中,以便执行这两种内容?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-10-18 00:00:06

您将需要从您自己的原始“组装”脚本中调用。类似于此

代码语言:javascript
复制
#!/bin/bash -e
# The assemble script builds the application artifacts from a source and 
# places them into appropriate directories inside the image.

# Execute the default S2I script
source ${STI_SCRIPTS_PATH}/assemble

# You can write S2I scripts in any programming language, as long as the 
# scripts are executable inside the builder image.
票数 2
EN

Stack Overflow用户

发布于 2022-08-27 07:44:56

使用OpenShift,我想要执行我自己的运行脚本(运行)。因此,我在应用程序的src中添加了一个文件./s2i/run,该文件稍微改变了默认运行文件https://github.com/sclorg/nginx-container/blob/master/1.20/s2i/bin/run

这是我的运行文件

代码语言:javascript
复制
#!/bin/bash
source /opt/app-root/etc/generate_container_user

set -e

source ${NGINX_CONTAINER_SCRIPTS_PATH}/common.sh

process_extending_files ${NGINX_APP_ROOT}/src/nginx-start ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start

if [ ! -v NGINX_LOG_TO_VOLUME -a -v NGINX_LOG_PATH ]; then
    /bin/ln -sf /dev/stdout ${NGINX_LOG_PATH}/access.log
    /bin/ln -sf /dev/stderr ${NGINX_LOG_PATH}/error.log
fi

#nginx will start using the custom nginx.conf from configmap
exec nginx -c /opt/mycompany/mycustomnginx/nginx-conf/nginx.conf -g "daemon    off;"

然后,更改dockerfile以执行我的运行脚本,如下所示,可以调用CMD命令一次,并指示部署荚启动时执行的脚本位于何处。

代码语言:javascript
复制
FROM registry.access.redhat.com/rhscl/nginx-120

# Add application sources to a directory that the assemble script expects them
# and set permissions so that the container runs without root access
USER 0

COPY dist/my-portal /tmp/src

COPY --chmod=0755 s2i /tmp/
RUN ls -la /tmp
USER 1001

# Let the assemble script to install the dependencies
RUN /usr/libexec/s2i/assemble

# Run script uses standard ways to run the application
#CMD /usr/libexec/s2i/run
# here we override the script that will be executed when the deployment pod starts
CMD /tmp/run
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46800608

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档