Skip to content

Commit 2f5b7de

Browse files
committed
k8s-tools
Tools for use and deploy on K8s in one image
1 parent c438ef7 commit 2f5b7de

2 files changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: 'build docker images: k8s tools'
2+
3+
on:
4+
#push:
5+
# branches:
6+
# - 'main'
7+
# - 'master'
8+
# paths:
9+
# - 'k8s-tools.alpine.Dockerfile'
10+
# - '.github/workflows/build_docker_images-k8s.yaml'
11+
workflow_dispatch:
12+
schedule:
13+
- cron: '30 5 28 * *' # At 05:30 on day-of-month 28.
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
docker:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Shell-Script
27+
id: script
28+
run: |
29+
BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
30+
BUILD_DATE_NUMERIC="${BUILD_DATE//[^[:digit:]]/}"
31+
COMMIT_HASH=${GITHUB_SHA::7}
32+
GITHUB_REPO=${GITHUB_REPOSITORY,,}
33+
GITHUB_REPO_SHORT=${GITHUB_REPO#*/}
34+
GITHUB_REPO_SHORT=${GITHUB_REPO_SHORT#"docker-"}
35+
DOCKER_REPO=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPO_SHORT}
36+
REDHAT_QUAY_REPO=${{ secrets.REDHAT_QUAY_USERNAME }}/${GITHUB_REPO_SHORT}
37+
38+
# Set output parameters to action.
39+
echo "build_date=${BUILD_DATE}" >> "$GITHUB_OUTPUT"
40+
echo "build_date_numeric=${BUILD_DATE_NUMERIC}" >> "$GITHUB_OUTPUT"
41+
echo "commit_hash=${COMMIT_HASH}" >> "$GITHUB_OUTPUT"
42+
echo "github_repo=${GITHUB_REPO}" >> "$GITHUB_OUTPUT"
43+
echo "docker_repo=${DOCKER_REPO}" >> "$GITHUB_OUTPUT"
44+
echo "redhat_quay_repo=${REDHAT_QUAY_REPO}" >> "$GITHUB_OUTPUT"
45+
46+
- name: Set up QEMU
47+
id: qemu
48+
uses: docker/setup-qemu-action@v3
49+
with:
50+
image: tonistiigi/binfmt:latest
51+
platforms: all
52+
53+
- name: Set up Docker Buildx
54+
id: buildx
55+
uses: docker/setup-buildx-action@v3
56+
57+
- name: Login to GitHub Container Registry
58+
uses: docker/login-action@v3
59+
with:
60+
registry: ghcr.io
61+
username: ${{ github.repository_owner }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Login to DockerHub
65+
uses: docker/login-action@v3
66+
with:
67+
registry: docker.io
68+
username: ${{ secrets.DOCKER_USERNAME }}
69+
password: ${{ secrets.DOCKER_PASSWORD }}
70+
71+
- name: Login to RED HAT Quay.io Container Registry
72+
uses: docker/login-action@v3
73+
with:
74+
registry: quay.io
75+
username: ${{ secrets.REDHAT_QUAY_USERNAME }}
76+
password: ${{ secrets.REDHAT_QUAY_PASSWORD }}
77+
78+
- name: Build
79+
uses: docker/build-push-action@v6
80+
with:
81+
builder: ${{ steps.buildx.outputs.name }}
82+
context: .
83+
file: ./k8s-tools.alpine.Dockerfile
84+
platforms: linux/amd64,linux/arm64,linux/arm/v7
85+
push: true
86+
#target: production
87+
build-args: |
88+
BUILD_DATE=${{steps.script.outputs.build_date}}
89+
VCS_REF=${{steps.script.outputs.commit_hash}}
90+
tags: |
91+
ghcr.io/${{steps.script.outputs.github_repo}}:k8s
92+
docker.io/${{steps.script.outputs.docker_repo}}:k8s
93+
quay.io/${{steps.script.outputs.redhat_quay_repo}}:k8s

k8s-tools.alpine.Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# docker build --no-cache --progress=plain -t tobi312/tools:k8s -f k8s-tools.alpine.Dockerfile .
2+
FROM alpine:latest AS production
3+
4+
SHELL ["/bin/ash", "-euxo", "pipefail", "-c"]
5+
6+
ARG VCS_REF
7+
ARG BUILD_DATE
8+
9+
LABEL org.opencontainers.image.title="K8s-Tools" \
10+
org.opencontainers.image.authors="Tobias Hargesheimer <docker@ison.ws>" \
11+
org.opencontainers.image.version="${VCS_REF}" \
12+
org.opencontainers.image.created="${BUILD_DATE}" \
13+
org.opencontainers.image.revision="${VCS_REF}" \
14+
org.opencontainers.image.description="Tools for use and deploy on K8s." \
15+
org.opencontainers.image.documentation="" \
16+
org.opencontainers.image.base.name="docker.io/library/alpine:latest" \
17+
org.opencontainers.image.licenses="WTFPL" \
18+
org.opencontainers.image.url="https://github.com/Tob1as/docker-tools" \
19+
org.opencontainers.image.source="https://github.com/Tob1as/docker-tools"
20+
21+
RUN \
22+
apk --no-cache add \
23+
bash \
24+
git \
25+
tar \
26+
gettext-envsubst \
27+
#curl \
28+
#etcd-ctl \
29+
#kubectl \
30+
#helm \
31+
#jq \
32+
##yq \
33+
make \
34+
; \
35+
echo ""
36+
37+
# https://hub.docker.com/r/tobi312/tools/tags?name=static
38+
COPY --from=tobi312/tools:static-curl /usr/bin/curl /usr/local/bin/curl
39+
COPY --from=tobi312/tools:static-etcdctl /usr/local/bin/etcdctl /usr/local/bin/etcdctl
40+
COPY --from=tobi312/tools:static-kubectl /usr/local/bin/kubectl /usr/local/bin/kubectl
41+
COPY --from=tobi312/tools:static-helm /usr/local/bin/helm /usr/local/bin/helm
42+
COPY --from=tobi312/tools:static-helm /root/.local/share/helm/plugins /root/.local/share/helm/plugins
43+
COPY --from=tobi312/tools:static-jq /usr/local/bin/jq /usr/local/bin/jq
44+
COPY --from=tobi312/tools:static-yq /usr/local/bin/yq /usr/local/bin/yq

0 commit comments

Comments
 (0)