Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .github/workflows/test-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
report-title: 'Kapitan tests'

build:
name: build ${{ matrix.platform }} image
name: build ${{ matrix.platform }} image using python ${{ matrix.python-version }}
if: success() || failure() # Continue running if other jobs fail
runs-on: ubuntu-latest
strategy:
Expand All @@ -91,6 +91,11 @@ jobs:
platform:
- linux/amd64
- linux/arm64
python-version:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
steps:
- name: Checkout kapitan recursively
uses: actions/checkout@v4
Expand All @@ -115,6 +120,8 @@ jobs:
tags: local-test-${{ matrix.platform }}
cache-from: type=gha,scope=$GITHUB_REF_NAME-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-${{ matrix.platform }}
build-args: |
- PYTHON_VERSION=${{ matrix.python-version }}

- name: Test Kapitan for ${{ matrix.platform }}
run: |
Expand All @@ -133,6 +140,15 @@ jobs:
platform:
- linux/amd64
- linux/arm64
python-version:
- '3.10'
- '3.11'
- '3.12'
- '3.13'
outputs:
python-version: ${{ matrix.python-version }}
platform: ${{ matrix.platform }}

steps:
- name: Checkout kapitan recursively
uses: actions/checkout@v4
Expand Down Expand Up @@ -163,7 +179,7 @@ jobs:
with:
# list of Docker images to use as base name for tags
images: |
name=${{ vars.DOCKERHUB_REPOSITORY }}/kapitan
name=${{ matrix.python-version }} == '3.11' && ${{ vars.DOCKERHUB_REPOSITORY }}/kapitan || ${{ vars.DOCKERHUB_REPOSITORY }}/kapitan-py${{ matrix.python-version }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
Expand All @@ -187,6 +203,8 @@ jobs:
labels: ${{steps.meta.outputs.labels}}
cache-from: type=gha,scope=$GITHUB_REF_NAME-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=$GITHUB_REF_NAME-${{ matrix.platform }}
build-args: |
- PYTHON_VERSION=${{ matrix.python-version }}

build-multi-architecture:
name: combine platform images
Expand Down Expand Up @@ -219,7 +237,7 @@ jobs:
with:
# list of Docker images to use as base name for tags
images: |
name=${{ vars.DOCKERHUB_REPOSITORY }}/kapitan
name=${{ needs.publish.outputs.python-version }} == '3.11' && ${{ vars.DOCKERHUB_REPOSITORY }}/kapitan || ${{ vars.DOCKERHUB_REPOSITORY }}/kapitan-py${{ needs.publish.outputs.python-version }}
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build the virtualenv for Kapitan
FROM python:3.11-slim AS python-builder
ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim AS python-builder
ARG TARGETARCH
ENV TARGETARCH=${TARGETARCH:-amd64}

Expand Down Expand Up @@ -44,11 +45,12 @@ COPY ./kapitan ./kapitan

RUN pip install .[gojsonnet,omegaconf,reclass-rs]

ARG PYTHON_VERSION=3.11
FROM golang:1 AS go-builder
RUN GOBIN=$(pwd)/ go install cuelang.org/go/cmd/cue@latest

# Final image with virtualenv built in previous step
FROM python:3.11-slim
FROM python:${PYTHON_VERSION}-slim

ENV PATH="/opt/venv/bin:${PATH}"
ENV HELM_CACHE_HOME=".cache/helm"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ To build a docker image for the architecture of your machine, run `docker build

To build a multi-platform image (as the CI does), follow [the docker multi-platform documentation](https://docs.docker.com/build/building/multi-platform/).

To build a docker image using a specific python version, run `docker build --build-arg PYTHON_BUILDER_VERSION=<python-version> . -t you-kapitan-image`. By default the Dockerfile is pinned using python 3.11 as the python builder version.

## Related projects

* [Tesoro](https://github.com/kapicorp/tesoro) - Kubernetes Admission Controller for Kapitan Secrets
Expand Down
Loading