Uploaded image for project: 'OpenShift Builds'
  1. OpenShift Builds
  2. BUILD-969

S2I cluster tasks do not use custom S2I scripts

XMLWordPrintable

    • False
    • None
    • False

      Description of problem:

      I'm using the S2I cluster task, such as s2i-ruby, and would like to use custom assemble script. S2I cluster tasks are designed to execute two containers named "generate" and "build-and-push". It seems that during the generate phase, the s2i command creates a Dockerfile, and during the build-and-push phase, it uses buildah command to build the image and push it.

      The issue arises from the fact that the source's ".s2i/bin" directory is not being referenced correctly when s2i command creates the Dockerfile during the generate phase. Although the path seems to be referenced correctly in the debug logs, it is not being reflected properly in the resulting Dockerfile.

      $ cat /gen-source/Dockerfile.gen
      FROM image-registry.openshift-image-registry.svc:5000/openshift/ruby:latest
      LABEL "io.openshift.s2i.build.image"="image-registry.openshift-image-registry.svc:5000/openshift/ruby:latest" \
            "io.openshift.s2i.build.source-location"="."
      
      USER root
      # Copying in source code
      COPY upload/src /tmp/src
      # Change file ownership to the assemble user. Builder image must support chown command.
      RUN chown -R 1001:0 /tmp/src
      USER 1001
      # Assemble script sourced from builder image based on user input or image metadata.
      # If this file does not exist in the image, the build will fail.
      RUN /usr/libexec/s2i/assemble <---- this is not a custom script
      # Run script sourced from builder image based on user input or image metadata.
      # If this file does not exist in the image, the build will fail.
      CMD /usr/libexec/s2i/run 

       

      The s2i command logs:

      I0312 02:33:08.280832      17 build.go:52] Running S2I version "unknown"
      I0312 02:33:08.281224      17 util.go:70] Getting docker credentials for image-registry.openshift-image-registry.svc:5000/openshift/ruby:latest
      I0312 02:33:08.281432      17 util.go:81] Using serviceaccount@example.org[image-registry.openshift-image-registry.svc:5000] credentials for pulling image-registry.openshift-image-registry.svc:5000/openshift/ruby:latest
      I0312 02:33:08.517391      17 build.go:170] 
      Source:				.
      Output Image Tag:		
      Environment:			
      Environment File:		/env-vars/env-file
      Labels:				
      Incremental Build:		disabled
      Remove Old Build:		disabled
      Builder Pull Policy:		if-not-present
      Previous Image Pull Policy:	if-not-present
      Quiet:				disabled
      Layered Build:			disabled
      Docker Endpoint:		unix:///var/run/docker.sock
      Docker Pull Config:		/tekton/home/.docker/config.json
      Docker Pull User:		serviceaccount
      
      I0312 02:33:08.517742      17 scm.go:20] DownloadForSource .
      I0312 02:33:08.518316      17 download.go:39] Copying sources from "." to "/gen-source/upload/src"
      I0312 02:33:08.518360      17 ignore.go:66] .s2iignore file does not exist
      I0312 02:33:08.518476      17 fs.go:247] Directory ".git" ignored
      I0312 02:33:08.518523      17 fs.go:250] D ".s2i" -> "/gen-source/upload/src/.s2i"
      I0312 02:33:08.518640      17 fs.go:250] D ".s2i/bin" -> "/gen-source/upload/src/.s2i/bin"
      I0312 02:33:08.518791      17 fs.go:268] F ".s2i/bin/assemble" -> "/gen-source/upload/src/.s2i/bin/assemble"
      I0312 02:33:08.518994      17 fs.go:268] F "Gemfile" -> "/gen-source/upload/src/Gemfile"
      I0312 02:33:08.520134      17 fs.go:268] F "Gemfile.lock" -> "/gen-source/upload/src/Gemfile.lock"
      I0312 02:33:08.520321      17 fs.go:268] F "README.md" -> "/gen-source/upload/src/README.md"
      I0312 02:33:08.520539      17 fs.go:268] F "Rakefile" -> "/gen-source/upload/src/Rakefile"
      I0312 02:33:08.520766      17 fs.go:268] F "app.rb" -> "/gen-source/upload/src/app.rb"
      I0312 02:33:08.520995      17 fs.go:268] F "config.ru" -> "/gen-source/upload/src/config.ru"
      I0312 02:33:08.521239      17 fs.go:268] F "index.html" -> "/gen-source/upload/src/index.html"
      I0312 02:33:08.521412      17 fs.go:250] D "pipeline" -> "/gen-source/upload/src/pipeline"
      I0312 02:33:08.521614      17 fs.go:268] F "pipeline/Jenkinsfile" -> "/gen-source/upload/src/pipeline/Jenkinsfile"
      I0312 02:33:08.521833      17 fs.go:268] F "pipeline/pipeline.yaml" -> "/gen-source/upload/src/pipeline/pipeline.yaml"
      I0312 02:33:08.522073      17 fs.go:250] D "test" -> "/gen-source/upload/src/test"
      I0312 02:33:08.522262      17 fs.go:268] F "test/test-app.rb" -> "/gen-source/upload/src/test/test-app.rb"
      I0312 02:33:08.522459      17 install.go:269] Using "assemble" installed from "<source-dir>/.s2i/bin/assemble"
      I0312 02:33:08.522583      17 install.go:269] Using "run" installed from "image:///usr/libexec/s2i/run"
      I0312 02:33:08.522694      17 install.go:269] Using "save-artifacts" installed from "image:///usr/libexec/s2i/save-artifacts"
      I0312 02:33:08.522784      17 ignore.go:66] .s2iignore file does not exist
      I0312 02:33:08.522832      17 dockerfile.go:115] Constructing image build context directory at /gen-source/
      I0312 02:33:08.522944      17 dockerfile.go:490] No user environment provided (no environment file found in application sources)
      I0312 02:33:08.522998      17 dockerfile.go:223] Processing injected inputs: api.VolumeList(nil)
      I0312 02:33:08.523059      17 dockerfile.go:225] Processed injected inputs: api.VolumeList(nil)
      I0312 02:33:08.523236      17 dockerfile.go:296] Wrote custom Dockerfile to /gen-source/Dockerfile.gen
      I0312 02:33:08.523331      17 build.go:180] Application dockerfile generated in /gen-source/Dockerfile.gen 

       

      Prerequisites (if any, like setup, operators/versions):

      OpenShift Container Platform 4.14

      Openshift Pipelines 1.14.0

      Steps to Reproduce

      1. Add custom scripts in the ".s2i/bin" directory in the source
      2. Execute a pipeline with S2I cluster tasks

      Actual results:

      Pipelines don't use custom S2I scripts

      Expected results:

      Pipelines use custom S2I scripts

      Reproducibility (Always/Intermittent/Only Once):

      Always

       

              rh-ee-asatyam Ayush Satyam
              rhn-support-shishika Shinri Ishikawa
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: