github.com/openshift/source-to-image@v1.4.1-0.20240516041539-bf52fc02204e/pkg/create/templates/scripts.go (about)

     1  package templates
     2  
     3  // AssembleScript is a default assemble script laid down by s2i create
     4  const AssembleScript = `#!/bin/bash -e
     5  #
     6  # S2I assemble script for the '{{.ImageName}}' image.
     7  # The 'assemble' script builds your application source so that it is ready to run.
     8  #
     9  # For more information refer to the documentation:
    10  #	https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
    11  #
    12  
    13  # If the '{{.ImageName}}' assemble script is executed with the '-h' flag, print the usage.
    14  if [[ "$1" == "-h" ]]; then
    15  	exec /usr/libexec/s2i/usage
    16  fi
    17  
    18  # Restore artifacts from the previous build (if they exist).
    19  #
    20  if [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then
    21    echo "---> Restoring build artifacts..."
    22    shopt -s dotglob
    23    mv /tmp/artifacts/* ./
    24    shopt -u dotglob
    25  fi
    26  
    27  echo "---> Installing application source..."
    28  cp -Rf /tmp/src/. ./
    29  
    30  echo "---> Building application from source..."
    31  # TODO: Add build steps for your application, eg npm install, bundle install, pip install, etc.
    32  `
    33  
    34  // RunScript is a default run script laid down by s2i create
    35  const RunScript = `#!/bin/bash -e
    36  #
    37  # S2I run script for the '{{.ImageName}}' image.
    38  # The run script executes the server that runs your application.
    39  #
    40  # For more information see the documentation:
    41  #	https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
    42  #
    43  
    44  exec asdf -p 8080
    45  `
    46  
    47  // UsageScript is a default usage script laid down by s2i create
    48  const UsageScript = `#!/bin/bash -e
    49  cat <<EOF
    50  This is the {{.ImageName}} S2I image:
    51  To use it, install S2I: https://github.com/openshift/source-to-image
    52  
    53  Sample invocation:
    54  
    55  s2i build <source code path/URL> {{.ImageName}} <application image>
    56  
    57  You can then run the resulting image via:
    58  docker run <application image>
    59  EOF
    60  `
    61  
    62  // SaveArtifactsScript is a default save artifacts script laid down by s2i
    63  // create
    64  const SaveArtifactsScript = `#!/bin/sh -e
    65  #
    66  # S2I save-artifacts script for the '{{.ImageName}}' image.
    67  # The save-artifacts script streams a tar archive to standard output.
    68  # The archive contains the files and folders you want to re-use in the next build.
    69  #
    70  # For more information see the documentation:
    71  #	https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
    72  #
    73  # tar cf - <list of files and folders>
    74  `