Skip to content

Commit

Permalink
feat: init container image with busybox and talosctl
Browse files Browse the repository at this point in the history
  • Loading branch information
tobikris committed Oct 7, 2024
1 parent 3a3b9a3 commit 1bc19b9
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build and publish container image

on:
push:
branches: ["main"]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v14.1
with:
files: |
Dockerfile
.github/workflows/**/*
- name: Log in to the Container registry
if: steps.changed-files.outputs.any_changed == 'true'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
if: steps.changed-files.outputs.any_changed == 'true'
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha
- name: Build and push Docker image
if: steps.changed-files.outputs.any_changed == 'true'
id: push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release new version of container image

on:
push:
tags: ["*"]
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=raw,value=latest
type=sha
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ARG TALOS_VERSION=latest
FROM ghcr.io/siderolabs/talosctl:$TALOS_VERSION AS talosctl


FROM ghcr.io/containerd/busybox:1.36

LABEL maintainer="Tobias Krischer <tobias.krischer@elyxon.de>"

COPY --from=talosctl /talosctl /usr/local/bin/talosctl
VOLUME [ "/var/run/secrets/talos.dev" ]
CMD [ "/bin/sh" ]

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Container image for talosctl based on busybox

Container image based on [ghcr.io/containerd/busybox](https://github.com/containerd/containerd/pkgs/container/busybox) with talosctl.
This image is useful for running shell scripts using talosctl (e.g. backup scripts).

## How to start

```sh
podman run \
-v $PWD/talosconfig.yaml:/var/run/secrets/talos.dev/config \
ghcr.io/nimbolus/container-talosctl
```

0 comments on commit 1bc19b9

Please sign in to comment.