diff --git a/.github/workflows/packages.yaml b/.github/workflows/packages.yaml index 645c2f8..74fef90 100644 --- a/.github/workflows/packages.yaml +++ b/.github/workflows/packages.yaml @@ -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 diff --git a/Dockerfile.fedora b/Dockerfile.fedora index e0de610..5b9d49d 100644 --- a/Dockerfile.fedora +++ b/Dockerfile.fedora @@ -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 diff --git a/Makefile b/Makefile index d7180fc..beaf9b5 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/packages/Dockerfile.kubectl b/packages/Dockerfile.kubectl new file mode 100644 index 0000000..5b84ca0 --- /dev/null +++ b/packages/Dockerfile.kubectl @@ -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 Jozelj " +LABEL org.opencontainers.image.source https://github.com/mentos1386/env + +COPY --from=build /root/kubectl / + diff --git a/packages/Dockerfile.starship b/packages/Dockerfile.starship index 1d8cb50..df0b583 100644 --- a/packages/Dockerfile.starship +++ b/packages/Dockerfile.starship @@ -11,7 +11,6 @@ RUN cargo build --release RUN strip target/release/starship FROM scratch AS binaries - LABEL maintainer="Tine Jozelj " LABEL org.opencontainers.image.source https://github.com/mentos1386/env