diff --git a/.gcloudignore b/.gcloudignore new file mode 100644 index 0000000..d2a0f03 --- /dev/null +++ b/.gcloudignore @@ -0,0 +1,6 @@ +.idea +.git +jenkins-x.yml +skaffold.yaml +*.md +build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e3cf7f4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# the jx binary for adding custom built jx to the image +jx +jxl + +.idea + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6be52ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,95 @@ +FROM google/cloud-sdk:slim + +RUN mkdir /out + +RUN yum install -y unzip + +# helmfile +ENV HELMFILE_VERSION 0.125.2 +RUN curl -LO https://github.com/roboll/helmfile/releases/download/v${HELMFILE_VERSION}/helmfile_linux_amd64 && \ + mv helmfile_linux_amd64 /out/helmfile && \ + chmod +x /out/helmfile + +# kubectl +ENV KUBECTL_VERSION 1.16.0 +RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl && \ + mv kubectl /out/kubectl && \ + chmod +x /out/kubectl + +# helm 3 +ENV HELM3_VERSION 3.2.4 +RUN curl -f -L https://get.helm.sh/helm-v${HELM3_VERSION}-linux-386.tar.gz | tar xzv && \ + mv linux-386/helm /out/ + +# terraform +ENV TERRAFORM 0.12.17 +RUN curl -LO https://releases.hashicorp.com/terraform/${TERRAFORM}/terraform_${TERRAFORM}_linux_amd64.zip && \ + unzip terraform_${TERRAFORM}_linux_amd64.zip && \ + chmod +x terraform && mv terraform /out && rm terraform_${TERRAFORM}_linux_amd64.zip + +ENV TERRAGRUNT_VERSION 0.21.2 +RUN curl -f -Lo terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_linux_amd64 && \ + chmod +x terragrunt && \ + mv terragrunt /out + +FROM golang:1.13 + +RUN mkdir /out +RUN mkdir -p /go/src/github.com/jenkins-x + +WORKDIR /go/src/github.com/jenkins-x + +RUN git clone https://github.com/jenkins-x/bdd-jx.git && \ + cd bdd-jx && \ + make testbin && \ + mv build/bddjx /out/bddjx + +# Adding the package path to local +ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin + + +# use a multi stage image so we don't include all the build tools above +FROM google/cloud-sdk:slim + + +# need to copy the whole git source else it doesn't clone the helm plugin repos below +COPY --from=0 /usr/local/git /usr/local/git +COPY --from=0 /usr/bin/make /usr/bin/make +COPY --from=0 /out /usr/local/bin +COPY --from=1 /out /usr/local/bin +COPY --from=0 /usr/local/gcloud /usr/local/gcloud + +# this is the directory used in pipelines for home dir +ENV HOME /builder/home + +# lets point jx plugins and helm at /home so we can pre-load binaries +ENV JX_HOME /home/.jx + +# these env vars are used to install helm plugins +ENV XDG_CACHE_HOME /home/.cache +ENV XDG_CONFIG_HOME /home/.config +ENV XDG_DATA_HOME /home/.data + +ENV PATH /usr/local/bin:/usr/local/git/bin:$PATH:/usr/local/gcloud/google-cloud-sdk/bin + +ENV JX_HELM3 "true" + +ENV DIFF_VERSION 3.1.1 + +RUN gcloud components install kpt --quiet +RUN gsutil cp gs://config-management-release/released/latest/linux_amd64/nomos /usr/local/bin/nomos +RUN mkdir -p /home/.jx/plugins/bin/ + +COPY helm-annotate/build/helm-annotate /home/.jx/plugins/bin/helmfile-0.0.11 + +RUN cp /usr/local/bin/helm /home/.jx/plugins/bin/helm-3.2.1 && \ + cp /usr/local/bin/helmfile /home/.jx/plugins/bin/helmfile-0.115.0 && \ + rm /usr/local/bin/helm /usr/local/bin/helmfile && \ + ln -s /home/.jx/plugins/bin/helm-3.2.1 /usr/local/bin/helm && \ + ln -s /home/.jx/plugins/bin/helm-annotate-0.0.11 /usr/local/bin/helm-annotate && \ + ln -s /home/.jx/plugins/bin/helmfile-0.115.0 /usr/local/bin/helmfile + + +RUN helm plugin install https://github.com/databus23/helm-diff --version ${DIFF_VERSION} && \ + helm plugin install https://github.com/aslafy-z/helm-git.git && \ + helm plugin install https://github.com/rawlingsj/helm-gcs diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7e219fe --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +clean-build: + rm -rf jx bdd-jx + +init: + mkdir -p build + +bddjx: init + git clone https://github.com/jenkins-x/bdd-jx.git + cd bdd-jx && ./build-bddjx-linux.sh + cp bdd-jx/build/bddjx-linux build + +jx: + git clone -b multicluster https://github.com/jenkins-x/jx.git + cd jx && make linux + cp jx/build/linux/jx build + +build: + git clone https://github.com/jenkins-x/helm-annotate.git && \ + cd helm-annotate && make build diff --git a/OWNERS b/OWNERS new file mode 100644 index 0000000..4865a41 --- /dev/null +++ b/OWNERS @@ -0,0 +1,4 @@ +approvers: +- jstrachan +reviewers: +- jstrachan diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES new file mode 100644 index 0000000..96ed6a4 --- /dev/null +++ b/OWNERS_ALIASES @@ -0,0 +1,6 @@ +aliases: +- jstrachan +best-approvers: +- jstrachan +best-reviewers: +- jstrachan diff --git a/README.md b/README.md new file mode 100644 index 0000000..08f32de --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# jx-cli base image + +The base image used for the [jenkins-x/jx-cli](https://github.com/jenkins-x/jx-cli) container image. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..2423995 --- /dev/null +++ b/build.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +if [ -z "$GCP_SA" ] +then + echo "no GCP SA specified" +else + echo "enabling GCP Service Account from $GCP_SA" + gcloud auth activate-service-account --key-file $GCP_SA +fi + + +echo "building container image version: $VERSION" + +gcloud builds submit --config cloudbuild.yaml --project jenkinsxio-labs-private --substitutions=_VERSION="$VERSION" + diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..877473b --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,12 @@ +steps: +- name: 'gcr.io/cloud-builders/docker' + args: [ 'build', '-t', 'gcr.io/jenkinsxio-labs-private/jx-cli-base:${_VERSION}', '.' ] +substitutions: + + _VERSION: 0.0.1 +timeout: 3600s +options: + machineType: 'N1_HIGHCPU_8' +logsBucket: gs://jenkinsxio-labs-private_cloudbuild +images: +- 'gcr.io/jenkinsxio-labs-private/jx-cli-base:${_VERSION}' \ No newline at end of file diff --git a/jenkins-x.yml b/jenkins-x.yml new file mode 100755 index 0000000..90e2672 --- /dev/null +++ b/jenkins-x.yml @@ -0,0 +1,31 @@ +buildPack: none +pipelineConfig: + pipelines: + pullRequest: + pipeline: + stages: + - agent: + image: gcr.io/kaniko-project/executor:debug-9912ccbf8d22bbafbf971124600fbb0b13b9cbd6 + name: chart + steps: + - name: make-build + command: make build + image: golang:1.13 + - name: build-and-push-image + command: /kaniko/executor --context=/workspace/source --dockerfile=/workspace/source/Dockerfile --destination=gcr.io/jenkinsxio-labs-private/jx-cli-base:$VERSION + release: + pipeline: + stages: + - agent: + image: gcr.io/kaniko-project/executor:debug-9912ccbf8d22bbafbf971124600fbb0b13b9cbd6 + name: chart + steps: + - name: make-build + command: make build + image: golang:1.13 + - name: build-and-push-image + command: /kaniko/executor --context=/workspace/source --dockerfile=/workspace/source/Dockerfile --destination=gcr.io/jenkinsxio-labs-private/jx-cli-base:$VERSION + - name: promote-release + command: ./promote.sh + dir: /workspace/source + image: gcr.io/jenkinsxio-labs-private/jxl \ No newline at end of file diff --git a/promote.sh b/promote.sh new file mode 100755 index 0000000..b2c5a7c --- /dev/null +++ b/promote.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo "promoting the new version ${VERSION} to downstream repositories" + +jx step create pr regex --regex "(?m)^FROM gcr.io/jenkinsxio-labs-private/jx-cli-base:(?P.*)$" --version ${VERSION} --files Dockerfile --repo https://github.com/jenkins-x/jx-cli.git + +jx step create pr regex --regex "(?m)^FROM gcr.io/jenkinsxio-labs-private/jx-cli-base:(?P.*)$" --version ${VERSION} --files Dockerfile --repo https://github.com/jenkins-x/jx-promote.git