Skip to content

Commit

Permalink
fix: first spike
Browse files Browse the repository at this point in the history
  • Loading branch information
jstrachan committed Aug 14, 2020
0 parents commit d1104f4
Show file tree
Hide file tree
Showing 11 changed files with 204 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea
.git
jenkins-x.yml
skaffold.yaml
*.md
build.sh
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# the jx binary for adding custom built jx to the image
jx
jxl

.idea

95 changes: 95 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
approvers:
- jstrachan
reviewers:
- jstrachan
6 changes: 6 additions & 0 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
aliases:
- jstrachan
best-approvers:
- jstrachan
best-reviewers:
- jstrachan
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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"

12 changes: 12 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -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}'
31 changes: 31 additions & 0 deletions jenkins-x.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions promote.sh
Original file line number Diff line number Diff line change
@@ -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 ${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 ${VERSION} --files Dockerfile --repo https://github.com/jenkins-x/jx-promote.git

0 comments on commit d1104f4

Please sign in to comment.