From 5a2b1a152109ab550382f326812e2b63d5f5ea2f Mon Sep 17 00:00:00 2001 From: Udo Waechter Date: Tue, 15 Mar 2022 12:34:17 +0100 Subject: [PATCH] git-clone taks and updates --- _CI-CD/tektoncd-git-clone-task.yaml | 101 +++++++++++++++++++++++++++ _CI-CD/tektoncd-kaniko-pipeline.yaml | 2 +- _CI-CD/tektoncd-kaniko-task.yaml | 3 +- apps/rompr/Dockerfile | 4 +- apps/rompr/tekton-pipelinerun.yaml | 2 +- 5 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 _CI-CD/tektoncd-git-clone-task.yaml diff --git a/_CI-CD/tektoncd-git-clone-task.yaml b/_CI-CD/tektoncd-git-clone-task.yaml new file mode 100644 index 0000000..97616a3 --- /dev/null +++ b/_CI-CD/tektoncd-git-clone-task.yaml @@ -0,0 +1,101 @@ +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: git-clone +spec: + workspaces: + - name: output + description: The git repo will be cloned onto the volume backing this workspace + params: + - name: url + description: git url to clone + type: string + default: http://git-ui.lan/chaos/kubernetes.git + - name: revision + description: git revision to checkout (branch, tag, sha, ref…) + type: string + default: master + - name: refspec + description: (optional) git refspec to fetch before checking out revision + default: "" + - name: submodules + description: defines if the resource should initialize and fetch the submodules + type: string + default: "true" + - name: depth + description: performs a shallow clone where only the most recent commit(s) will be fetched + type: string + default: "1" + - name: sslVerify + description: defines if http.sslVerify should be set to true or false in the global git config + type: string + default: "true" + - name: subdirectory + description: subdirectory inside the "output" workspace to clone the git repo into + type: string + default: "" + - name: deleteExisting + description: clean out the contents of the repo's destination directory (if it already exists) before trying to clone the repo there + type: string + default: "false" + - name: httpProxy + description: git HTTP proxy server for non-SSL requests + type: string + default: "" + - name: httpsProxy + description: git HTTPS proxy server for SSL requests + type: string + default: "" + - name: noProxy + description: git no proxy - opt out of proxying HTTP/HTTPS requests + type: string + default: "" + results: + - name: commit + description: The precise commit SHA that was fetched by this Task + steps: + - name: clone + image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.12.1 + script: | + CHECKOUT_DIR="$(workspaces.output.path)/$(params.subdirectory)" + + cleandir() { + # Delete any existing contents of the repo directory if it exists. + # + # We don't just "rm -rf $CHECKOUT_DIR" because $CHECKOUT_DIR might be "/" + # or the root of a mounted volume. + if [[ -d "$CHECKOUT_DIR" ]] ; then + # Delete non-hidden files and directories + rm -rf "$CHECKOUT_DIR"/* + # Delete files and directories starting with . but excluding .. + rm -rf "$CHECKOUT_DIR"/.[!.]* + # Delete files and directories starting with .. plus any other character + rm -rf "$CHECKOUT_DIR"/..?* + fi + } + + if [[ "$(params.deleteExisting)" == "true" ]] ; then + cleandir + fi + + test -z "$(params.httpProxy)" || export HTTP_PROXY=$(params.httpProxy) + test -z "$(params.httpsProxy)" || export HTTPS_PROXY=$(params.httpsProxy) + test -z "$(params.noProxy)" || export NO_PROXY=$(params.noProxy) + + /ko-app/git-init \ + -url "$(params.url)" \ + -revision "$(params.revision)" \ + -refspec "$(params.refspec)" \ + -path "$CHECKOUT_DIR" \ + -sslVerify="$(params.sslVerify)" \ + -submodules="$(params.submodules)" \ + -depth "$(params.depth)" + cd "$CHECKOUT_DIR" + RESULT_SHA="$(git rev-parse HEAD | tr -d '\n')" + EXIT_CODE="$?" + if [ "$EXIT_CODE" != 0 ] + then + exit $EXIT_CODE + fi + # Make sure we don't add a trailing newline to the result! + echo -n "$RESULT_SHA" > $(results.commit.path) \ No newline at end of file diff --git a/_CI-CD/tektoncd-kaniko-pipeline.yaml b/_CI-CD/tektoncd-kaniko-pipeline.yaml index d8f6a49..ec8995d 100644 --- a/_CI-CD/tektoncd-kaniko-pipeline.yaml +++ b/_CI-CD/tektoncd-kaniko-pipeline.yaml @@ -21,7 +21,7 @@ spec: - name: revision value: $(params.git-revision) - name: submodules - value: '0' + value: false workspaces: - name: output workspace: git-source diff --git a/_CI-CD/tektoncd-kaniko-task.yaml b/_CI-CD/tektoncd-kaniko-task.yaml index 248e9de..2879b19 100644 --- a/_CI-CD/tektoncd-kaniko-task.yaml +++ b/_CI-CD/tektoncd-kaniko-task.yaml @@ -33,7 +33,8 @@ spec: default: [] - name: BUILDER_IMAGE description: The image on which builds will run (default is v1.5.1) - default: gcr.io/kaniko-project/executor:v1.5.1@sha256:c6166717f7fe0b7da44908c986137ecfeab21f31ec3992f6e128fff8a94be8a5 + default: gcr.io/kaniko-project/executor:v1.8.0 + #default: gcr.io/kaniko-project/executor:v1.5.1@sha256:c6166717f7fe0b7da44908c986137ecfeab21f31ec3992f6e128fff8a94be8a5 workspaces: - name: source description: Holds the context and docker file diff --git a/apps/rompr/Dockerfile b/apps/rompr/Dockerfile index 1f530d0..a67b63d 100644 --- a/apps/rompr/Dockerfile +++ b/apps/rompr/Dockerfile @@ -21,7 +21,7 @@ RUN mkdir -p /rompr RUN ln -sf /rompr/prefs /app/rompr/prefs RUN ln -sf /rompr/albumart /app/rompr/albumart RUN chown -R www-data:www-data /app/rompr /rompr -ADD nginx_default /etc/nginx/sites-available/default +ADD /files/nginx_default /etc/nginx/sites-available/default RUN mkdir -p /run/php/ #Environment variables to configure php RUN sed -ri -e 's/^allow_url_fopen =.*/allow_url_fopen = On/g' /etc/php/7.4/fpm/php.ini @@ -35,7 +35,7 @@ RUN sed -ri -e 's/^display_startup_errors =.*/display_startup_errors = On/g' /e RUN echo "" > /app/rompr/phpinfo.php RUN update-rc.d php7.4-fpm defaults -ADD run-httpd /usr/local/bin/ +ADD /files/run-httpd /usr/local/bin/ RUN chmod 755 /usr/local/bin/run-httpd EXPOSE 80 VOLUME ["/rompr"] diff --git a/apps/rompr/tekton-pipelinerun.yaml b/apps/rompr/tekton-pipelinerun.yaml index b1b4c19..1579d35 100644 --- a/apps/rompr/tekton-pipelinerun.yaml +++ b/apps/rompr/tekton-pipelinerun.yaml @@ -11,7 +11,7 @@ spec: - name: git-revision value: master - name: path-to-image-context - value: /files + value: ./ - name: path-to-dockerfile value: /apps/rompr/Dockerfile - name: image-name