地方エンジニアの学習日記

興味ある技術の雑なメモだったりを書いてくブログ。たまに日記とガジェット紹介。

tecton manifest サンプル

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: s2i-java-8
spec:
  inputs:
    resources:
      - name: source
        type: git
    params:
      - name: PATH_CONTEXT
        description: The location of the path to run s2i from
        default: .
        type: string
      - name: TLSVERIFY
        description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)
        default: "true"
        type: string
      - name: MAVEN_ARGS_APPEND
        description: Additional Maven arguments
        default: ""
        type: string
      - name: MAVEN_CLEAR_REPO
        description: Remove the Maven repository after the artifact is built
        default: "false"
        type: string
      - name: MAVEN_MIRROR_URL
        description: The base URL of a mirror used for retrieving artifacts
        default: ""
        type: string
  outputs:
    resources:
      - name: image
        type: image
  steps:
    - name: gen-env-file
      image: quay.io/openshift-pipeline/s2i
      workingdir: /env-params
      command:
        - '/bin/sh'
        - '-c'
      args:
        - |-
          echo "MAVEN_CLEAR_REPO=$(inputs.params.MAVEN_CLEAR_REPO)" > env-file

          [[ '$(inputs.params.MAVEN_ARGS_APPEND)' != "" ]] &&
            echo "MAVEN_ARGS_APPEND=$(inputs.params.MAVEN_ARGS_APPEND)" >> env-file

          [[ '$(inputs.params.MAVEN_MIRROR_URL)' != "" ]] &&
            echo "MAVEN_MIRROR_URL=$(inputs.params.MAVEN_MIRROR_URL)" >> env-file

          echo "Generated Env file"
          echo "------------------------------"
          cat env-file
          echo "------------------------------"
      volumeMounts:
        - name: envparams
          mountPath: /env-params
    - name: generate
      image: quay.io/openshift-pipeline/s2i
      workingdir: /workspace/source
      command:
        - 's2i'
        - 'build'
        - '$(inputs.params.PATH_CONTEXT)'
        - 'registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift'
        - '--image-scripts-url'
        - 'image:///usr/local/s2i'
        - '--as-dockerfile'
        - '/gen-source/Dockerfile.gen'
        - '--environment-file'
        - '/env-params/env-file'
      volumeMounts:
        - name: gen-source
          mountPath: /gen-source
        - name: envparams
          mountPath: /env-params
    - name: build
      image: quay.io/buildah/stable
      workingdir: /gen-source
      command: ['buildah', 'bud', '--tls-verify=$(inputs.params.TLSVERIFY)', '--layers', '-f', '/gen-source/Dockerfile.gen', '-t', '$(outputs.resources.image.url)', '.']
      volumeMounts:
        - name: varlibcontainers
          mountPath: /var/lib/containers
        - name: gen-source
          mountPath: /gen-source
      securityContext:
        privileged: true
    - name: push
      image: quay.io/buildah/stable
      command: ['buildah', 'push', '--tls-verify=$(inputs.params.TLSVERIFY)', '$(outputs.resources.image.url)', 'docker://$(outputs.resources.image.url)']
      volumeMounts:
        - name: varlibcontainers
          mountPath: /var/lib/containers
      securityContext:
        privileged: true
  volumes:
    - name: varlibcontainers
      emptyDir: {}
    - name: gen-source
      emptyDir: {}
    - name: envparams
      emptyDir: {}