Skip to content

A Docker Hub image for CI/CD deployments, with tools like curl, dind, docker-compose, kind, kubectl, helm, bitwarden, etc

Notifications You must be signed in to change notification settings

emilioforrer/ci-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI Tools - Docker hub image


Description


CI Tools is a Docker Hub image for CI/CD deployments, with tools like curl, dind, docker-compose, kind, kubectl, helm, vault, 1password, semver-cli, argo-cd, bitwarden, waypoint, earthly etc.

Tools and dependencies

Name Version Command
git 2.34.1 git version
bash 5.1.8(1)-release bash --version
yq 2.13.0 yq --version
jq v3.15.0_alpha20210804-4073 jq --version
curl 7.80.0 curl --version
docker 20.10.12 docker --version
docker-compose 1.29.2 docker-compose --version
kind 0.11.1 kind --version
kubectl v1.23.3 kubectl version --client
helm v3.8.0 helm version
vault v1.9.3 vault --version
1password 1.12.4 op --version
bitwarden 1.21.0 bw --version
semver-cli 1.1.0 --
argocd v2.2.5+8f981cc argocd version --client
waypoint v0.7.1 waypoint --version
earthly v0.6.7 earthly --version

Note: to see a list of changes for supported tags and dependency versions, please see the CHANGELOG.md

Usage


Bash

This image has a custom colored bash and prints the STERR in red color and new extra commands:

Note: in order to set up the bash and import the commands, you can run source /scripts/.bashrc;

Command - generate_service_account_kubeconfig

Is a new command that generates a kubeconfig file based on the service account token, while running in a pod.

e.g.

generate_service_account_kubeconfig;
export KUBECONFIG="$(pwd)/kubeconfig";

With parameters (API_SERVER, FILE_NAME)

generate_service_account_kubeconfig "https://kubernetes.default.svc.cluster.local" "kubeconfig-dev";
export KUBECONFIG="$(pwd)/kubeconfig-dev";
Command - println

Is a new command that accepts as a first parameter a color and a second parameter a text to print (if no color given, it prints the text with the default color).

e.g.

Print the text in red color hello

println r "hello"

Print the text as warning (yellow) color hello

println warn "hello"

Print the text in cyan color hello

println cyan "hello"

Print the text in default color hello

println "hello"

List of colors

Name Short name
black bk
red r
green g
yellow y
blue b
purple p
cyan c
white wh
info i
warn (yellow) w
error (red) e
sucsess (green) ok

DIND (Docker in Docker)

DIND is a way to run Docker inside a Docker container (for example, to pull and build images, or to run other containers) in your CI/CD system.

docker run --rm -it \
           -v /var/run/docker.sock:/var/run/docker.sock \
           emilioforrer/ci-tools:latest \
           bash

Inside the image you can run sudo docker version or

docker run --rm -it \
           -v /var/run/docker.sock:/var/run/docker.sock \
           emilioforrer/ci-tools:latest \
           sudo docker version

Docker compose

Docker compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services.

e.g. Create a docker-compose.yaml file.

cat << EOF > docker-compose.yaml
version: "3.7"
services:
  nginx-hello:
    image: emilioforrer/nginx-hello
    ports:
      - '8000:80'
  ruby-hello:
    image: emilioforrer/ruby-hello
    network_mode: "host"
    ports:
      - '5000:5000'
  python-hello:
    image: emilioforrer/python-hello
    network_mode: "host"
    ports:
      - '5000:5000'
  nodejs-hello:
    image: emilioforrer/nodejs-hello
    network_mode: "host"
    environment:
      URLS: 'http://0.0.0.0:7000,http://0.0.0.0:3000,http://0.0.0.0:4000,http://0.0.0.0:5000'
    ports:
      - '9000:9000'
  php-hello:
    image: emilioforrer/php-hello
    network_mode: "host"
    ports:
      - '7000:7000'
  elixir-hello:
    image: emilioforrer/elixir-hello
    network_mode: "host"
    ports:
      - '4000:4000'
    environment:
      RUBY_URL: 'http://0.0.0.0:3000'
      PHP_URL: 'http://0.0.0.0:7000'
EOF

And then run

docker run --rm -it \
           -v /var/run/docker.sock:/var/run/docker.sock \
           -v $(pwd)/:/home/developer/workspace \
           emilioforrer/ci-tools:latest \
           sudo docker-compose up

Now open your favorite browser and visit http://localhost:5001/

KIND (Kubernetes In Docker)

KIND kind is a tool for running local Kubernetes clusters using Docker container "nodes". kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.

e.g.

docker run --rm -it \
           -v /var/run/docker.sock:/var/run/docker.sock \
           -v $(pwd)/:/home/developer/workspace \
           emilioforrer/ci-tools:latest \
           sudo kind create cluster

Kubectl

Kubectl Kubectl is a command line tool for controlling Kubernetes clusters.

e.g.

docker run --rm -v "$KUBECONFIG:$KUBECONFIG" \
           -e KUBECONFIG=$KUBECONFIG \
           emilioforrer/ci-tools:latest kubectl version

Helm

Helm Helm is the best way to find, share, and use software built for Kubernetes.

docker run -v $(pwd)/:/home/developer/workspace \
           emilioforrer/ci-tools:latest \
           helm version

GIT

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

e.g. Clonning a repository in the current working directory of the host.

docker run -v $(pwd)/:/home/developer/workspace \
           emilioforrer/ci-tools:latest \
           git clone https://github.com/emilioforrer/ci-tools.git

yq

yq is a lightweight and portable command-line YAML processor

e.g. Create a yaml and get a node.

cat <<EOF > pod.yaml
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: myapp-container
    image: busybox
    command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']
EOF

Get the container name

docker run -v $(pwd)/:/home/developer/workspace \
           emilioforrer/ci-tools:latest \
           yq '.spec.containers[0].name' pod.yaml

jq

jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.

e.g. Create a json and get a node.

cat <<EOF > pod.json
{
  "apiVersion": "v1",
  "kind": "Pod",
  "metadata": {
    "name": "myapp-pod",
    "labels": {
      "app": "myapp"
    }
  },
  "spec": {
    "containers": [
      {
        "name": "myapp-container",
        "image": "busybox",
        "command": [
          "sh",
          "-c",
          "echo Hello Kubernetes! && sleep 3600"
        ]
      }
    ]
  }
}
EOF

Get the container name

docker run -v $(pwd)/:/home/developer/workspace \
           emilioforrer/ci-tools:latest \
           jq '.spec.containers[0].name' pod.json

curl

curl is used in command lines or scripts to transfer data. It is also used in cars, television sets, routers, printers, audio equipment, mobile phones, tablets, settop boxes, media players and is the internet transfer backbone for thousands of software applications affecting billions of humans daily.

e.g

docker run -v $(pwd)/:/home/developer/workspace \
           emilioforrer/ci-tools:latest \
           curl -fG https://raw.githubusercontent.com/emilioforrer/ci-tools/develop/README.md > README.md

Vault CLI

vault is a secure, store and tightly control access to tokens, passwords, certificates, encryption keys for protecting secrets and other sensitive data using a UI, CLI, or HTTP API.

e.g

docker run -v $(pwd)/:/home/developer/workspace \
           emilioforrer/ci-tools:latest \
           vault --version

1Password CLI

1Password with 1Password you only ever need to memorize one password. All your other passwords and important information are protected by your Master Password, which only you know. e.g

docker run -it emilioforrer/ci-tools:latest op --version

Bitwarden CLI

Bitwarden Open Source Password Management for You and Your Business. he easiest and safest way for individuals and businesses to store, share, and secure sensitive data on any device e.g

docker run -it emilioforrer/ci-tools:latest bw --version

Waypoint CLI

waypoint-cli allows developers to deploy, manage, and observe their applications through a consistent abstraction of underlying infrastructure. e.g

docker run -it emilioforrer/ci-tools:latest waypoint --help

Earthly CLI

earthly-cli is a syntax for defining your build. It works with your existing build system. Get repeatable and understandable builds today. e.g

# In order to use `earthly bootstrap` inside the image without sudo, you need to add `--group-add $(stat -c '%g' /var/run/docker.sock)` 
docker run -it -v /var/run/docker.sock:/var/run/docker.sock --group-add $(stat -c '%g' /var/run/docker.sock) emilioforrer/ci-tools:latest earthly --help

Semver CLI

semver-cli is a simple command line tool to compare and manipulate version strings. e.g

docker run -it emilioforrer/ci-tools:latest semver --help

Development

Scripts

Build Docker image

# Build Docker image
./build.sh
# Build and push Docker image
DOCKER_PUSH=true ./build.sh

Note: Before pushing an image, make sure to change the release version in the VERSION file.