Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .scripts/actions/get_build_arguments.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# Splits comma-separated values, prepends them with --build-arg, and prints
# them out separated by newlines.
echo "$1" | awk '{ split($0, args, ","); for (i in args) { printf "--build-arg \"%s\" ", args[i] }}'
5 changes: 3 additions & 2 deletions build-container-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ All subsequent tasks must use this value to ensure consistency.

### Inputs

- `image-name` (eg: `kafka`)
- `image-index-manifest-tag` (eg: `3.4.1-stackable0.0.0-dev`)
- `image-name` (required, eg: `kafka`)
- `image-index-manifest-tag` (required, eg: `3.4.1-stackable0.0.0-dev`)
- `container-file` (defaults to `Dockerfile`)
- `build-context` (defaults to `.`)
- `build-arguments`

### Outputs

Expand Down
23 changes: 15 additions & 8 deletions build-container-image/action.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Build Product Image
description: This action builds a product Docker image with a specific version
name: Build Container Image
description: This action builds a container image with a specific version
inputs:
image-name:
description: |
Expand All @@ -12,11 +12,14 @@ inputs:
Human-readable tag (usually the version) without architecture information,
for example: `3.4.1-stackable0.0.0-dev`
container-file:
description: Path to Containerfile (or Dockefile)
description: Path to Containerfile (or Dockerfile)
default: Dockerfile
build-context:
description: Path to the build-context
default: .
build-arguments:
description: |
A comma-separated list of KEY=VALUE pairs provided as build arguments
outputs:
image-repository-uri:
description: |
Expand Down Expand Up @@ -45,10 +48,13 @@ runs:
IMAGE_INDEX_MANIFEST_TAG: ${{ inputs.image-index-manifest-tag }}
CONTAINER_FILE: ${{ inputs.container-file }}
BUILD_CONTEXT: ${{ inputs.build-context }}
BUILD_ARGUMENTS: ${{ inputs.build-arguments }}
shell: bash
run: |
set -euo pipefail

DOCKER_BUILD_ARGUMENTS=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_build_arguments.sh" "$BUILD_ARGUMENTS")

IMAGE_ARCH=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_architecture.sh")
echo "IMAGE_ARCH=${IMAGE_ARCH}" | tee -a "$GITHUB_ENV"

Expand All @@ -64,11 +70,12 @@ runs:
echo "::group::docker buildx build"
# TODO (@NickLarsenNZ): Allow optional buildx cache
docker buildx build \
--file "${CONTAINER_FILE}" \
--platform "linux/${IMAGE_ARCH}" \
--tag "${IMAGE_MANIFEST_URI}" \
--load \
"${BUILD_CONTEXT}"
--file "${CONTAINER_FILE}" \
--platform "linux/${IMAGE_ARCH}" \
--tag "${IMAGE_MANIFEST_URI}" \
--load \
$DOCKER_BUILD_ARGUMENTS \
"${BUILD_CONTEXT}"
echo "::endgroup::"

echo "::group::docker images"
Expand Down