feat(oci): Build using pure Buildah

I prefer control everything to build images
This commit is contained in:
2025-08-13 09:47:59 +02:00
parent b13e922966
commit 37c7998412
2 changed files with 35 additions and 27 deletions

View File

@@ -1,37 +1,43 @@
name: Build OCI image name: Build and push OCI image
on: on:
release: push:
types: tags:
- published - "**"
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }} IMAGE_NAME: ${{ github.repository }}
VERSION: ${{ github.ref_name }}
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - name: Install Buildah
with: run: |-
registry: ${{ env.REGISTRY }} if ! comamnd -v buildah 2>/dev/null; then
username: ${{ github.actor }} echo "Install Buildah"
password: ${{ secrets.GITHUB_TOKEN }} apt-get update
- name: Set up QEMU apt-get install -y buildah
uses: docker/setup-qemu-action@v3 else
- name: Set up Docker Buildx echo "Buildah already installed"
uses: docker/setup-buildx-action@v3 fi
- name: Build and push
uses: docker/build-push-action@v6 - name: Build and tag
with: run: |-
context: . buildah build --build-arg VERSION=$VERSION -t katenary -f ./oci/katenary/Containerfile .
file: ./oci/katenary/Containerfile buildah tag katenary $REGISTRY/${IMAGE_NAME,,}:$VERSION
push: true buildah tag katenary $REGISTRY/${IMAGE_NAME,,}:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} - name: Push image
build-args: | run: |-
VERSION=${{github.ref_name}} buildah login $REGISTRY -u ${{ github.actor }} -p ${{ secret.GITHUB_TOKEN }}
buildah push $REGISTRY/${IMAGE_NAME,,}:$VERSION
buildah push $REGISTRY/${IMAGE_NAME,,}:latest

View File

@@ -1,15 +1,17 @@
ARG GOVERSION=1.24 ARG GOVERSION=1.24
FROM docker.io/golang:${GOVERSION} AS builder FROM docker.io/golang:${GOVERSION} AS builder
WORKDIR /go/src/github.com/katenary/katenary
COPY . .
ARG VERSION=master ARG VERSION=master
RUN set -xe; \ RUN set -xe; \
CGO_ENABLED=0 go install -v github.com/katenary/katenary/cmd/katenary@$VERSION; CGO_ENABLED=0 go build -ldflags="-X 'github.com/katenary/katenary/internal/generator.Version=$VERSION'" -trimpath -o katenary ./cmd/katenary
FROM scratch FROM scratch
LABEL org.opencontainers.image.source=https://github.com/katenary/katenary LABEL org.opencontainers.image.source=https://github.com/katenary/katenary
LABEL org.opencontainers.image.description="Katenary converts compose files to Helm Chart" LABEL org.opencontainers.image.description="Katenary converts compose files to Helm Chart"
LABEL org.opencontainers.image.licenses=MIT LABEL org.opencontainers.image.licenses=MIT
COPY --from=builder /go/bin/katenary /usr/local/bin/katenary COPY --from=builder /go/src/github.com/katenary/katenary/katenary /katenary
VOLUME /project VOLUME /project
WORKDIR /project WORKDIR /project
ENTRYPOINT ["/usr/local/bin/katenary"] ENTRYPOINT ["/katenary"]