diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..7cf8237 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,40 @@ +name: build + +on: + workflow_dispatch: + inputs: + tag: + description: Tag of image. Note that latest is used with the demo.yaml and kumactl! + required: true + type: string + push: + description: Whether to push the images + required: true + default: false + type: boolean +permissions: + contents: read + +env: + DOCKER_REPO: kumahq/kuma-demo + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + if: ${{ fromJSON(inputs.push) }} + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_API_KEY }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: ${{ fromJSON(inputs.push) }} + platforms: linux/amd64, linux/arm64 + tags: ${{ env.DOCKER_REPO }}:${{ inputs.tag }} diff --git a/release/Dockerfile b/Dockerfile similarity index 100% rename from release/Dockerfile rename to Dockerfile index a9d3a97..c167980 100644 --- a/release/Dockerfile +++ b/Dockerfile @@ -2,8 +2,8 @@ ARG ARCH=amd64 FROM --platform=linux/${ARCH} node:alpine RUN apk add dumb-init -COPY /app/package.json /app/package.json +COPY /app/package.json /app/package.json RUN npm install --prefix /app COPY /app/public /app/public diff --git a/release/RELEASE.md b/release/RELEASE.md deleted file mode 100644 index c2afa3e..0000000 --- a/release/RELEASE.md +++ /dev/null @@ -1,9 +0,0 @@ -## How to release `kuma-demo` image? - -Kuma supports `amd64` and `arm64` architecture. To build and push multi-platform image you there is script that support this. Run: - -```bash -DOCKER_USERNAME= DOCKER_API_KEY= DRY_RUN= ./release/docker.sh -``` - -If you want to push your images than you need to set environment `DRY_RUN=false`, by default is true. \ No newline at end of file diff --git a/release/docker.sh b/release/docker.sh deleted file mode 100755 index fd6458b..0000000 --- a/release/docker.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash - -set -e - -KUMA_DOCKER_REPO="${KUMA_DOCKER_REPO:-docker.io}" -KUMA_DOCKER_REPO_ORG="${KUMA_DOCKER_REPO_ORG:-${KUMA_DOCKER_REPO}/kumahq}" -BUILD_ARCH="${BUILD_ARCH:-amd64 arm64}" -VERSION="${VERSION:-latest}" -DRY_RUN="${DRY_RUN:-true}" - -function build_and_push() { - for arch in ${BUILD_ARCH}; do - echo "Building kuma-demo..." - docker build --pull --build-arg ARCH="${arch}" -t "${KUMA_DOCKER_REPO_ORG}/kuma-demo:latest-${arch}" -f release/Dockerfile . - if [ $VERSION != "latest" ]; then - docker tag "${KUMA_DOCKER_REPO_ORG}/kuma-demo:latest-${arch}" "${KUMA_DOCKER_REPO_ORG}/kuma-demo:${VERSION}-${arch}" - fi - if [ $DRY_RUN != "true" ]; then - echo "Pushing kuma-demo:$VERSION-$arch ..." - docker push "${KUMA_DOCKER_REPO_ORG}/kuma-demo:${VERSION}-${arch}" - echo "... done!" - fi - echo "... done!" - done - if [ $DRY_RUN != "true" ]; then - images=() - for arch in ${BUILD_ARCH}; do - images+=("--amend ${KUMA_DOCKER_REPO_ORG}/kuma-demo:${VERSION}-${arch}") - done - command="docker manifest create ${KUMA_DOCKER_REPO_ORG}/kuma-demo:${VERSION} ${images[*]}" - echo "Creating manifest for ${KUMA_DOCKER_REPO_ORG}/kuma-demo:${VERSION}..." - eval "$command" - echo "Pushing manifest ${KUMA_DOCKER_REPO_ORG}/kuma-demo:${VERSION} ..." - docker manifest push "${KUMA_DOCKER_REPO_ORG}/kuma-demo:${VERSION}" - echo ".. done!" - fi -} - -if [ $DRY_RUN != "true" ]; then - [ -z "$DOCKER_USERNAME" ] && echo "\$DOCKER_USERNAME required" - [ -z "$DOCKER_API_KEY" ] && echo "\$DOCKER_API_KEY required" -fi -build_and_push