diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 4bce130..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,84 +0,0 @@ -.defaults: &defaults - working_directory: ~/circulate - docker: - - image: buildpack-deps:trusty - -.install-docker-client: &install-docker-client - name: Install docker client - command: | - DOCKER_CLIENT_VERSION="17.11.0-ce" - curl --location --output /tmp/docker-$DOCKER_CLIENT_VERSION.tgz https://download.docker.com/linux/static/edge/x86_64/docker-$DOCKER_CLIENT_VERSION.tgz - tar --extract --gzip --directory /tmp -f /tmp/docker-$DOCKER_CLIENT_VERSION.tgz - mv /tmp/docker/* /usr/bin -.build-docker-image: &build-docker-image - steps: - - checkout - - setup_remote_docker - - run: - <<: *install-docker-client - - run: - name: Build docker image - command: docker image build --no-cache --tag $DOCKER_REPOSITORY:latest . - - run: - name: Install Goss and Dgoss - command: | - GOSS_VERSION="0.3.5" - curl -L https://github.com/aelsabbahy/goss/releases/download/v$GOSS_VERSION/goss-linux-amd64 -o /usr/local/bin/goss - curl -L https://raw.githubusercontent.com/aelsabbahy/goss/v$GOSS_VERSION/extras/dgoss/dgoss -o /usr/local/bin/dgoss - chmod +rx /usr/local/bin/goss - chmod +rx /usr/local/bin/dgoss - - run: - name: Test docker image - command: dgoss run $DOCKER_REPOSITORY:latest sleep 100 - - run: - name: Save docker image to archive - command: | - mkdir -p /tmp/docker-images - docker save $DOCKER_REPOSITORY:latest --output /tmp/docker-images/image.tar.gz - - persist_to_workspace: - root: /tmp - paths: - - docker-images - -version: 2 -jobs: - build-and-test-docker-image: - <<: *defaults - <<: *build-docker-image - - retag-and-push-into-registry: - <<: *defaults - steps: - - setup_remote_docker - - attach_workspace: - at: /tmp - - run: - <<: *install-docker-client - - run: - name: Load docker image - command: docker load --input /tmp/docker-images/image.tar.gz - - run: - name: Login to Docker hub - command: docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD - - run: - name: Push image to docker registy - command: | - docker tag $DOCKER_REPOSITORY:latest $DOCKER_REPOSITORY:$CIRCLE_TAG - docker image push $DOCKER_REPOSITORY:$CIRCLE_TAG - docker image push $DOCKER_REPOSITORY:latest -workflows: - version: 2 - release-image: - jobs: - - build-and-test-docker-image: - filters: - tags: - only: /[0-9]+\.[0-9]+\.[0-9]+/ - - retag-and-push-into-registry: - requires: - - build-and-test-docker-image - filters: - tags: - only: /[0-9]+\.[0-9]+\.[0-9]+/ - branches: - ignore: /.*/ \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab8764b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.idea +/nbproject +.DS_Store diff --git a/Dockerfile b/Dockerfile index a927298..6b7ac8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,69 +1,70 @@ FROM alpine:3.6 -LABEL maintainer="petr.pliska@post.cz" - ENV DOCKER_CLIENT_VERSION="18.05.0-ce" ENV TERRAFORM_VERSION="0.11.7" -ENV HELM_VERSION="2.9.1" ENV KUBECTL_VERSION="1.11.1" -ENV GOSS_VERSION="0.3.6" ENV YQ_VERSION="2.1.1" -ENV CLOUD_SDK_VERSION 206.0.0 -ENV PATH /tmp/google-cloud-sdk/bin:$PATH +ENV KUSTOMIZE_VERSION="1.0.10" +ENV CLOUD_SDK_VERSION="206.0.0" +ENV PATH /opt/google-cloud-sdk/bin:$PATH WORKDIR /tmp -# Buildpack-deps basic requirements +# Install dependencies RUN apk add --update --no-cache \ - ca-certificates \ - curl \ - gnupg \ - wget \ - tar \ - unzip && \ - # Install git vcs - apk add --update --no-cache \ - git \ - openssl \ - openssh-client \ - bash && \ - # Install Docker client, Helm, Terraform, Kubectlx - curl --location https://download.docker.com/linux/static/edge/x86_64/docker-$DOCKER_CLIENT_VERSION.tgz --output /tmp/docker-$DOCKER_CLIENT_VERSION.tgz && \ - tar --extract --gzip --directory /tmp --file /tmp/docker-$DOCKER_CLIENT_VERSION.tgz && \ - mv /tmp/docker/* /usr/bin && \ - rm -rf /tmp/* && \ - curl --location https://storage.googleapis.com/kubernetes-helm/helm-v$HELM_VERSION-linux-amd64.tar.gz --output helm.tar.gz && \ - tar --extract --file helm.tar.gz && \ - mv linux-amd64/helm /usr/bin/helm && \ - rm -rf linux-amd64 helm.tar.gz && \ - curl --location https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip --output terraform.zip && \ - unzip terraform.zip && \ - mv terraform /usr/bin/terraform && \ - rm -rf terraform.zip && \ - curl --location https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl --output /usr/bin/kubectl && \ - chmod +x /usr/bin/kubectl && \ - curl --location https://github.com/aelsabbahy/goss/releases/download/v$GOSS_VERSION/goss-linux-amd64 --output /usr/local/bin/goss && \ - curl --location https://raw.githubusercontent.com/aelsabbahy/goss/v$GOSS_VERSION/extras/dgoss/dgoss --output /usr/local/bin/dgoss && \ - chmod +rx /usr/local/bin/goss && \ - chmod +rx /usr/local/bin/dgoss && \ - wget --output-document=/usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/$YQ_VERSION/yq_linux_amd64 && \ - chmod +x /usr/local/bin/yq + bash \ + ca-certificates \ + curl \ + git \ + gnupg \ + libc6-compat \ + openssh-client \ + py-crcmod \ + python \ + tar \ + unzip \ + wget \ + && rm -rf /var/cache/apk/* + +# Install Docker +RUN curl --location https://download.docker.com/linux/static/edge/x86_64/docker-${DOCKER_CLIENT_VERSION}.tgz --output /tmp/docker.tgz && \ + tar --extract --gzip --directory /tmp --file /tmp/docker.tgz && \ + mv /tmp/docker/* /usr/local/bin && \ + docker --version && \ + rm -rf /tmp/* + +# Install Terraform +RUN curl --location https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip --output terraform.zip && \ + unzip terraform.zip && \ + mv terraform /usr/local/bin/terraform && \ + terraform --version && \ + rm -rf /tmp/* + +# Install Kubectl +RUN curl --location https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl --output /usr/local/bin/kubectl && \ + chmod +x /usr/local/bin/kubectl && \ + kubectl version --client -o yaml + +# Install yq +RUN curl --location https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 --output /usr/local/bin/yq && \ + chmod +x /usr/local/bin/yq && \ + yq --version + +# Install Kustomize +RUN curl --location https://github.com/kubernetes-sigs/kustomize/releases/download/v${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64 --output /usr/local/bin/kustomize && \ + chmod +x /usr/local/bin/kustomize && \ + kustomize version -RUN apk --no-cache add \ - curl \ - python \ - py-crcmod \ - bash \ - libc6-compat \ - openssh-client \ - git \ - && curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \ - tar xzf google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \ - rm google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz && \ +# Install Google Cloud SDK +RUN curl --location https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz --output google-cloud-sdk.tar.gz && \ + tar xzf google-cloud-sdk.tar.gz && \ + mkdir -p /opt/google-cloud-sdk && \ + mv google-cloud-sdk/* /opt/google-cloud-sdk && \ ln -s /lib /lib64 && \ + gcloud --version && \ gcloud config set core/disable_usage_reporting true && \ gcloud config set component_manager/disable_update_check true && \ gcloud config set metrics/environment github_docker_image && \ - gcloud --version + rm -rf /tmp/* -VOLUME ["/root/.config"] \ No newline at end of file +VOLUME ["/root/.config"] diff --git a/README.md b/README.md new file mode 100644 index 0000000..9978c66 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# Kubernetes Build Pack +Kubernetes Build pack serves to build and deploy [Shopsys Framework](https://github.com/shopsys/shopsys) application using Docker, Kubernetes, Terraform etc. that are preinstalled into Dockerfile which can be used later as an image. + +## Requirements +Docker + +## What it contains +[Docker](https://www.docker.com/) + +[Kubernetes - kubectl](https://kubernetes.io/) + +[Terraform](https://www.terraform.io/) + +[Yq](https://github.com/kislyuk/yq) + +[Google Cloud SDK](https://cloud.google.com/sdk/) + +[Kustomize](https://github.com/kubernetes-sigs/kustomize) + +## How to use +Basic concept of usage of this image is to mount your repository into container volume from which you can perform all your tasks related to deploying Shopsys Framework. + +*Code example*: + +``` +cd /my-project/ + +docker run \ + -v $PWD:/tmp \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v ~/.kube/config:/root/.kube/config \ + shopsys/kubernetes-buildpack + --rm + +``` + +## How to extend +What if I want to work with some technology that is not included in shopsys/kubernetes-buildpack? + +You can extend our image in `Dockerfile` and install applications and tools that you require. + +```Dockerfile +FROM shopsys/kubernetes-buildpack + +# install tools you want here, eg. Python +RUN apk add --update --no-cache python3 +``` \ No newline at end of file diff --git a/goss.yaml b/goss.yaml deleted file mode 100644 index 0084e70..0000000 --- a/goss.yaml +++ /dev/null @@ -1,66 +0,0 @@ -package: - bash: - installed: true - versions: - - 4.3.48-r1 - ca-certificates: - installed: true - versions: - - 20161130-r2 - curl: - installed: true - versions: - - 7.61.0-r0 - git: - installed: true - versions: - - 2.13.7-r0 - gnupg: - installed: true - versions: - - 2.1.20-r1 - openssh-client: - installed: true - versions: - - 7.5_p1-r2 - openssl: - installed: true - versions: - - 1.0.2o-r1 - tar: - installed: true - versions: - - 1.29-r1 - unzip: - installed: true - versions: - - 6.0-r2 - wget: - installed: true - versions: - - 1.19.5-r0 -command: - docker --version: - exit-status: 0 - stdout: - - {{.Env.DOCKER_CLIENT_VERSION}} - goss --version: - exit-status: 0 - stdout: - - {{.Env.GOSS_VERSION}} - helm version --client: - exit-status: 0 - stdout: - - {{.Env.HELM_VERSION}} - kubectl version --client: - exit-status: 0 - stdout: - - {{.Env.KUBECTL_VERSION}} - terraform --version: - exit-status: 0 - stdout: - - {{.Env.TERRAFORM_VERSION}} - yq --version: - exit-status: 0 - stdout: - - {{.Env.YQ_VERSION}} \ No newline at end of file