feat(oci): Use Buildah
And set version the right way...
This commit is contained in:
40
.github/workflows/build-oci.yaml
vendored
40
.github/workflows/build-oci.yaml
vendored
@@ -1,9 +1,9 @@
|
|||||||
name: Build OCI image
|
name: Build OCI image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
release:
|
push:
|
||||||
types:
|
tags:
|
||||||
- published
|
- "**"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
@@ -12,26 +12,28 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Log in to the Container registry
|
- name: Build image
|
||||||
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
|
id: build-image
|
||||||
|
uses: redhat-actions/buildah-build@v2
|
||||||
with:
|
with:
|
||||||
|
image: ghcr.io/katenary/katenary
|
||||||
|
tags: latest ${{ github.ref_name }}
|
||||||
|
containerfiles: |
|
||||||
|
./oci/katenary/Containerfile
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ github.ref_name }}
|
||||||
|
- name: Push image
|
||||||
|
id: push-to-quay
|
||||||
|
uses: redhat-actions/push-to-registry@v2
|
||||||
|
with:
|
||||||
|
image: ${{ steps.build-image.outputs.image }}
|
||||||
|
tags: ${{ steps.build-image.outputs.tags }}
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./oci/katenary/Containerfile
|
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
build-args: |
|
|
||||||
VERSION=${{github.ref_name}}
|
|
||||||
|
@@ -1,15 +1,26 @@
|
|||||||
ARG GOVERSION=1.24
|
ARG GOVERSION=1.24
|
||||||
|
|
||||||
FROM docker.io/golang:${GOVERSION} AS builder
|
FROM docker.io/golang:${GOVERSION} AS builder
|
||||||
ARG VERSION=master
|
ARG VERSION
|
||||||
|
RUN \
|
||||||
|
if [ "${VERSION}" = "" ]; then\
|
||||||
|
echo "You must set VERSION build argument"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
COPY go.mod go.sum /go/src/github.com/katenary/katenary/
|
||||||
|
COPY cmd /go/src/github.com/katenary/katenary/cmd
|
||||||
|
COPY internal /go/src/github.com/katenary/katenary/internal
|
||||||
|
WORKDIR /go/src/github.com/katenary/katenary
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
RUN set -xe; \
|
RUN set -xe; \
|
||||||
CGO_ENABLED=0 go install -v github.com/katenary/katenary/cmd/katenary@$VERSION;
|
go build -ldflags="-X 'github.com/katenary/katenary/internal/generator.Version=v${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 /usr/local/bin/katenary
|
||||||
VOLUME /project
|
VOLUME /project
|
||||||
WORKDIR /project
|
WORKDIR /project
|
||||||
ENTRYPOINT ["/usr/local/bin/katenary"]
|
ENTRYPOINT ["/usr/local/bin/katenary"]
|
||||||
|
Reference in New Issue
Block a user