我希望澄清可以添加到项目repo中.s2i/bin目录中的可能脚本。
文档说,当您添加这些文件时,它们将在构建项目时重写相同名称的默认文件()。例如,如果我将自己的“汇编”文件放置在.s2i/bin目录中,默认的汇编文件也会运行,还是会被脚本完全替换?如果我想要默认文件的一些行为怎么办?我是否必须将默认的“组装”内容复制到我的文件中,以便执行这两种内容?
发布于 2017-10-18 00:00:06
您将需要从您自己的原始“组装”脚本中调用。类似于此
#!/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.发布于 2022-08-27 07:44:56
使用OpenShift,我想要执行我自己的运行脚本(运行)。因此,我在应用程序的src中添加了一个文件./s2i/run,该文件稍微改变了默认运行文件https://github.com/sclorg/nginx-container/blob/master/1.20/s2i/bin/run。
这是我的运行文件
#!/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命令一次,并指示部署荚启动时执行的脚本位于何处。
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/runhttps://stackoverflow.com/questions/46800608
复制相似问题