feat(packages:kubectl): add kubectl package

This commit is contained in:
Tine Jozelj 2020-12-23 19:45:44 +01:00
parent 2dc1800005
commit 2cd31fbd3c
No known key found for this signature in database
GPG key ID: 3818B74E3830D7CF
5 changed files with 81 additions and 6 deletions

View file

@ -7,6 +7,59 @@ on:
branches: main
jobs:
kubectl:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=ghcr.io/mentos1386/kubectl
DOCKER_PLATFORMS=linux/amd64,linux/arm64
VERSION=1.20.0
TAGS="--tag ${DOCKER_IMAGE}:${VERSION} --tag ${DOCKER_IMAGE}:latest"
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
${TAGS} --file ./packages/Dockerfile.starship .
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-kubectl-${{ github.sha }}
restore-keys: |
${{ runner.os }}-kubectl-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Login to Github Registry
if: success() && github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Docker Buildx (push)
if: success() && github.event_name != 'pull_request'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Inspect image
if: always() && github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
starship:
runs-on: ubuntu-latest
steps:
@ -34,9 +87,9 @@ jobs:
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
key: ${{ runner.os }}-starship-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-starship-
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx

View file

@ -31,8 +31,9 @@ RUN set -ueox pipefail \
&& dnf clean all \
&& rm -rf /tmp/* /var/tmp/*
# Install self compiled packages
# Install other packages
COPY --from=ghcr.io/mentos1386/starship:0.47.0 /starship /usr/local/bin/starship
COPY --from=ghcr.io/mentos1386/kubectl:1.20.0 /kubectl /usr/local/bin/kubectl
# Create .dotfiles
COPY --chown=${SSH_USER}:${SSH_USER} dotfiles /home/${SSH_USER}/.dotfiles

View file

@ -6,8 +6,13 @@ fedora:
ubuntu:
@docker buildx build --load -t env-ubuntu -f Dockerfile.ubuntu .
packages:
@docker buildx build --load -t starship:0.47.0 -f packages/Dockerfile.starship packages/
package-starship:
@docker buildx build --load -t starship -f packages/Dockerfile.starship packages/
package-kubectl:
@docker buildx build --load -t kubectl -f packages/Dockerfile.kubectl packages/
packages: package-kubectl package-starship
all: packages fedora ubuntu

View file

@ -0,0 +1,17 @@
FROM alpine:3 as build
WORKDIR /root
RUN apk --no-cache add curl
ARG VERSION=1.20.0
RUN curl -LO "https://storage.googleapis.com/kubernetes-release/release/${VERSION}/bin/${TARGETPLATFORM}/kubectl"
RUN chmod +x kubectl
FROM scratch AS binaries
LABEL maintainer="Tine <mentos1386> Jozelj <tine@tjo.space>"
LABEL org.opencontainers.image.source https://github.com/mentos1386/env
COPY --from=build /root/kubectl /

View file

@ -11,7 +11,6 @@ RUN cargo build --release
RUN strip target/release/starship
FROM scratch AS binaries
LABEL maintainer="Tine <mentos1386> Jozelj <tine@tjo.space>"
LABEL org.opencontainers.image.source https://github.com/mentos1386/env