Skip to content

Commit

Permalink
Merge pull request #159 from leojonathanoh/enhancement/add-yq-in-comp…
Browse files Browse the repository at this point in the history
…osite-variants

Enhancement: Add `yq` in composite variants
  • Loading branch information
leojonathanoh authored Jul 19, 2024
2 parents f854bac + 6083dd3 commit 7536263
Show file tree
Hide file tree
Showing 38 changed files with 1,448 additions and 293 deletions.
510 changes: 255 additions & 255 deletions .github/workflows/ci-master-pr.yml

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,39 @@ Dockerized `kubectl` with useful tools.
| Tag | Dockerfile Build Context |
|:-------:|:---------:|
| `:1.30.3`, `:latest` | [View](variants/1.30.3) |
| `:1.30.3-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.30.3-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.30.3-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.30.3-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.29.7` | [View](variants/1.29.7) |
| `:1.29.7-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.29.7-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.29.7-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.29.7-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.28.12` | [View](variants/1.28.12) |
| `:1.28.12-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.28.12-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.28.12-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.28.12-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.27.16` | [View](variants/1.27.16) |
| `:1.27.16-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.27.16-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.27.16-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.27.16-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.26.15` | [View](variants/1.26.15) |
| `:1.26.15-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.26.15-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.26.15-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.26.15-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.25.16` | [View](variants/1.25.16) |
| `:1.25.16-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.25.16-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.25.16-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.25.16-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.24.17` | [View](variants/1.24.17) |
| `:1.24.17-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.24.17-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.24.17-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.24.17-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.23.17` | [View](variants/1.23.17) |
| `:1.23.17-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.23.17-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.23.17-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.23.17-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.22.17` | [View](variants/1.22.17) |
| `:1.22.17-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.22.17-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.22.17-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.22.17-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.21.14` | [View](variants/1.21.14) |
| `:1.21.14-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.21.14-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.21.14-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.21.14-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.20.15` | [View](variants/1.20.15) |
| `:1.20.15-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.20.15-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.20.15-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.20.15-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.19.16` | [View](variants/1.19.16) |
| `:1.19.16-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.19.16-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.19.16-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.19.16-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.18.20` | [View](variants/1.18.20) |
| `:1.18.20-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.18.20-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.18.20-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.18.20-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.17.17` | [View](variants/1.17.17) |
| `:1.17.17-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.17.17-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.17.17-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.17.17-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.16.15` | [View](variants/1.16.15) |
| `:1.16.15-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.16.15-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.16.15-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.16.15-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.15.12` | [View](variants/1.15.12) |
| `:1.15.12-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.15.12-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.15.12-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.15.12-envsubst-git-jq-kustomize-sops-ssh-yq) |
| `:1.14.10` | [View](variants/1.14.10) |
| `:1.14.10-envsubst-git-jq-kustomize-sops-ssh` | [View](variants/1.14.10-envsubst-git-jq-kustomize-sops-ssh) |
| `:1.14.10-envsubst-git-jq-kustomize-sops-ssh-yq` | [View](variants/1.14.10-envsubst-git-jq-kustomize-sops-ssh-yq) |

All variants are based on `alpine`.

Expand Down
2 changes: 1 addition & 1 deletion generate/definitions/VARIANTS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $local:VARIANTS_MATRIX = @(
distro_version = '3.15'
subvariants = @(
@{ components = @(); tag_as_latest = if ($v -eq ($local:VERSIONS.kubectl.versions | ? { $_ -match '^\d+\.\d+\.\d+$' } | Select-Object -First 1 )) { $true } else { $false } }
@{ components = @( 'envsubst', 'git', 'jq', 'kustomize', 'sops', 'ssh' ) }
@{ components = @( 'envsubst', 'git', 'jq', 'kustomize', 'sops', 'ssh', 'yq' ) }
)
}
}
Expand Down
22 changes: 2 additions & 20 deletions generate/templates/Dockerfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,12 @@ RUN apk add --no-cache openssh-client
'@
}

'sockets' {
'yq' {
@'
# Sockets
# See: https://github.com/docker-library/php/issues/181#issuecomment-173365852
RUN docker-php-ext-install sockets
'@

}

'xdebug' {
@'
# Xdebug: https://stackoverflow.com/questions/46825502/how-do-i-install-xdebug-on-dockers-official-php-fpm-alpine-image
# PHPIZE_DEPS: autoconf dpkg-dev dpkg file g++ gcc libc-dev make pkgconf re2c
RUN apk add --no-cache --virtual .build-dependencies $PHPIZE_DEPS \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& docker-php-source delete \
&& apk del .build-dependencies
RUN apk add --no-cache jq
'@

}

default {
Expand Down
59 changes: 59 additions & 0 deletions variants/1.14.10-envsubst-git-jq-kustomize-sops-ssh-yq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM alpine:3.15
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"

RUN apk add --no-cache ca-certificates

# When $TARGETPLATFORM is linux/arm/v7, strip out the '/v6' or '/v7' from it
RUN BIN_URL=https://storage.googleapis.com/kubernetes-release/release/v1.14.10/bin/$( echo $TARGETPLATFORM | sed 's@/v[67]$@@' )/kubectl \
&& SHA512=$( wget -qO- "$BIN_URL.sha512" ) \
&& wget -qO- "$BIN_URL" > /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl \
&& sha512sum /usr/local/bin/kubectl | grep "^$SHA512 " \
&& kubectl version --client

# From: https://github.com/nginxinc/docker-nginx/blob/1.17.0/stable/alpine/Dockerfile
# Bring in gettext so we can get `envsubst`, then throw
# the rest away. To do this, we need to install `gettext`
# then move `envsubst` out of the way so `gettext` can
# be deleted completely, then move `envsubst` back.
RUN apk add --no-cache --virtual .gettext gettext \
&& mv /usr/bin/envsubst /tmp/ \
\
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache $runDeps \
&& apk del .gettext \
&& mv /tmp/envsubst /usr/local/bin/

RUN apk add --no-cache git

RUN apk add --no-cache jq

RUN apk add --no-cache curl \
&& curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 -o /usr/local/bin/kustomize \
&& chmod +x /usr/local/bin/kustomize \
&& apk del curl

RUN set -eux; \
wget -qO- https://github.com/mozilla/sops/releases/download/v3.7.1/sops-v3.7.1.linux > /usr/local/bin/sops; \
chmod +x /usr/local/bin/sops; \
sha256sum /usr/local/bin/sops | grep '^185348fd77fc160d5bdf3cd20ecbc796163504fd3df196d7cb29000773657b74 '; \
sops --version

RUN apk add --no-cache gnupg

RUN apk add --no-cache openssh-client

RUN apk add --no-cache jq

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT [ "/docker-entrypoint.sh" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu

if [ $# -gt 0 ] && [ "${1#-}" != "$1" ]; then
set -- kubectl "$@"
elif [ $# -gt 0 ] && kubectl "$1" --help > /dev/null 2>&1; then
set -- kubectl "$@"
fi

exec "$@"
59 changes: 59 additions & 0 deletions variants/1.15.12-envsubst-git-jq-kustomize-sops-ssh-yq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM alpine:3.15
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"

RUN apk add --no-cache ca-certificates

# When $TARGETPLATFORM is linux/arm/v7, strip out the '/v6' or '/v7' from it
RUN BIN_URL=https://storage.googleapis.com/kubernetes-release/release/v1.15.12/bin/$( echo $TARGETPLATFORM | sed 's@/v[67]$@@' )/kubectl \
&& SHA512=$( wget -qO- "$BIN_URL.sha512" ) \
&& wget -qO- "$BIN_URL" > /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl \
&& sha512sum /usr/local/bin/kubectl | grep "^$SHA512 " \
&& kubectl version --client

# From: https://github.com/nginxinc/docker-nginx/blob/1.17.0/stable/alpine/Dockerfile
# Bring in gettext so we can get `envsubst`, then throw
# the rest away. To do this, we need to install `gettext`
# then move `envsubst` out of the way so `gettext` can
# be deleted completely, then move `envsubst` back.
RUN apk add --no-cache --virtual .gettext gettext \
&& mv /usr/bin/envsubst /tmp/ \
\
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache $runDeps \
&& apk del .gettext \
&& mv /tmp/envsubst /usr/local/bin/

RUN apk add --no-cache git

RUN apk add --no-cache jq

RUN apk add --no-cache curl \
&& curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 -o /usr/local/bin/kustomize \
&& chmod +x /usr/local/bin/kustomize \
&& apk del curl

RUN set -eux; \
wget -qO- https://github.com/mozilla/sops/releases/download/v3.7.1/sops-v3.7.1.linux > /usr/local/bin/sops; \
chmod +x /usr/local/bin/sops; \
sha256sum /usr/local/bin/sops | grep '^185348fd77fc160d5bdf3cd20ecbc796163504fd3df196d7cb29000773657b74 '; \
sops --version

RUN apk add --no-cache gnupg

RUN apk add --no-cache openssh-client

RUN apk add --no-cache jq

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT [ "/docker-entrypoint.sh" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu

if [ $# -gt 0 ] && [ "${1#-}" != "$1" ]; then
set -- kubectl "$@"
elif [ $# -gt 0 ] && kubectl "$1" --help > /dev/null 2>&1; then
set -- kubectl "$@"
fi

exec "$@"
59 changes: 59 additions & 0 deletions variants/1.16.15-envsubst-git-jq-kustomize-sops-ssh-yq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM alpine:3.15
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"

RUN apk add --no-cache ca-certificates

# When $TARGETPLATFORM is linux/arm/v7, strip out the '/v6' or '/v7' from it
RUN BIN_URL=https://storage.googleapis.com/kubernetes-release/release/v1.16.15/bin/$( echo $TARGETPLATFORM | sed 's@/v[67]$@@' )/kubectl \
&& SHA512=$( wget -qO- "$BIN_URL.sha512" ) \
&& wget -qO- "$BIN_URL" > /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl \
&& sha512sum /usr/local/bin/kubectl | grep "^$SHA512 " \
&& kubectl version --client

# From: https://github.com/nginxinc/docker-nginx/blob/1.17.0/stable/alpine/Dockerfile
# Bring in gettext so we can get `envsubst`, then throw
# the rest away. To do this, we need to install `gettext`
# then move `envsubst` out of the way so `gettext` can
# be deleted completely, then move `envsubst` back.
RUN apk add --no-cache --virtual .gettext gettext \
&& mv /usr/bin/envsubst /tmp/ \
\
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache $runDeps \
&& apk del .gettext \
&& mv /tmp/envsubst /usr/local/bin/

RUN apk add --no-cache git

RUN apk add --no-cache jq

RUN apk add --no-cache curl \
&& curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 -o /usr/local/bin/kustomize \
&& chmod +x /usr/local/bin/kustomize \
&& apk del curl

RUN set -eux; \
wget -qO- https://github.com/mozilla/sops/releases/download/v3.7.1/sops-v3.7.1.linux > /usr/local/bin/sops; \
chmod +x /usr/local/bin/sops; \
sha256sum /usr/local/bin/sops | grep '^185348fd77fc160d5bdf3cd20ecbc796163504fd3df196d7cb29000773657b74 '; \
sops --version

RUN apk add --no-cache gnupg

RUN apk add --no-cache openssh-client

RUN apk add --no-cache jq

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT [ "/docker-entrypoint.sh" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu

if [ $# -gt 0 ] && [ "${1#-}" != "$1" ]; then
set -- kubectl "$@"
elif [ $# -gt 0 ] && kubectl "$1" --help > /dev/null 2>&1; then
set -- kubectl "$@"
fi

exec "$@"
59 changes: 59 additions & 0 deletions variants/1.17.17-envsubst-git-jq-kustomize-sops-ssh-yq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM alpine:3.15
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"

RUN apk add --no-cache ca-certificates

# When $TARGETPLATFORM is linux/arm/v7, strip out the '/v6' or '/v7' from it
RUN BIN_URL=https://storage.googleapis.com/kubernetes-release/release/v1.17.17/bin/$( echo $TARGETPLATFORM | sed 's@/v[67]$@@' )/kubectl \
&& SHA512=$( wget -qO- "$BIN_URL.sha512" ) \
&& wget -qO- "$BIN_URL" > /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl \
&& sha512sum /usr/local/bin/kubectl | grep "^$SHA512 " \
&& kubectl version --client

# From: https://github.com/nginxinc/docker-nginx/blob/1.17.0/stable/alpine/Dockerfile
# Bring in gettext so we can get `envsubst`, then throw
# the rest away. To do this, we need to install `gettext`
# then move `envsubst` out of the way so `gettext` can
# be deleted completely, then move `envsubst` back.
RUN apk add --no-cache --virtual .gettext gettext \
&& mv /usr/bin/envsubst /tmp/ \
\
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache $runDeps \
&& apk del .gettext \
&& mv /tmp/envsubst /usr/local/bin/

RUN apk add --no-cache git

RUN apk add --no-cache jq

RUN apk add --no-cache curl \
&& curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.3/kustomize_2.0.3_linux_amd64 -o /usr/local/bin/kustomize \
&& chmod +x /usr/local/bin/kustomize \
&& apk del curl

RUN set -eux; \
wget -qO- https://github.com/mozilla/sops/releases/download/v3.7.1/sops-v3.7.1.linux > /usr/local/bin/sops; \
chmod +x /usr/local/bin/sops; \
sha256sum /usr/local/bin/sops | grep '^185348fd77fc160d5bdf3cd20ecbc796163504fd3df196d7cb29000773657b74 '; \
sops --version

RUN apk add --no-cache gnupg

RUN apk add --no-cache openssh-client

RUN apk add --no-cache jq

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh

ENTRYPOINT [ "/docker-entrypoint.sh" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu

if [ $# -gt 0 ] && [ "${1#-}" != "$1" ]; then
set -- kubectl "$@"
elif [ $# -gt 0 ] && kubectl "$1" --help > /dev/null 2>&1; then
set -- kubectl "$@"
fi

exec "$@"
Loading

0 comments on commit 7536263

Please sign in to comment.