diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index afde5f4f..71b4ccee 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -1,6 +1,11 @@ name: CI Build -on: [push] +on: + push: + branches: + - '**' + tags-ignore: + - '**' jobs: ubuntu-build: diff --git a/.github/workflows/publish-docker-images.yml b/.github/workflows/publish-docker-images.yml new file mode 100644 index 00000000..3ba2f5d5 --- /dev/null +++ b/.github/workflows/publish-docker-images.yml @@ -0,0 +1,187 @@ +name: Publish Docker Images + +on: + workflow_dispatch: + inputs: + zrok-version: + description: zrok release tag to publish as a Docker image + type: string + required: true + release: + types: + - published + +jobs: + publish-docker-images: + runs-on: ubuntu-latest + env: + RELEASE_REF: ${{ inputs.zrok-version || github.ref }} + steps: + # compose the semver string without leading "refs/tags" or "v" so we can predict the + # release artifact filename + - name: Set zrok Version Semver from Tag Ref + id: semver + run: | + zrok_semver=${RELEASE_REF#refs/tags/} + echo "zrok_semver=${zrok_semver#v}" >> $GITHUB_OUTPUT + + - name: Checkout Workspace + uses: actions/checkout@v3 + + - name: Create the Release Arch Dirs + run: | + for TGZ in dist/{amd,arm}64/linux/; do + mkdir -pv ${TGZ} + done + + - name: Download Linux AMD64 Release Artifact + uses: dsaltares/fetch-gh-release-asset@master + with: + version: tags/v${{ steps.semver.outputs.zrok_semver }} + file: zrok_${{ steps.semver.outputs.zrok_semver }}_linux_amd64.tar.gz + target: dist/amd64/linux/zrok_${{ steps.semver.outputs.zrok_semver }}_linux_amd64.tar.gz + + - name: Download Linux ARM64 Release Artifact + uses: dsaltares/fetch-gh-release-asset@master + with: + version: tags/v${{ steps.semver.outputs.zrok_semver }} + file: zrok_${{ steps.semver.outputs.zrok_semver }}_linux_arm64.tar.gz + target: dist/arm64/linux/zrok_${{ steps.semver.outputs.zrok_semver }}_linux_arm64.tar.gz + + - name: Unpack the Release Artifacts + run: | + for TGZ in dist/{amd,arm}64/linux; do + tar -xvzf ${TGZ}/zrok_*.tar.gz -C ${TGZ} + done + + - name: Set Up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: amd64,arm64 + + - name: Set Up Docker BuildKit + id: buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_API_USER }} + password: ${{ secrets.DOCKER_HUB_API_TOKEN }} + + - name: Set Up Container Image Tags for zrok CLI Container + env: + RELEASE_REPO: openziti/zrok + ZROK_VERSION: ${{ steps.semver.outputs.zrok_semver }} + id: tagprep_cli + run: | + DOCKER_TAGS="" + DOCKER_TAGS="${RELEASE_REPO}:${ZROK_VERSION},${RELEASE_REPO}:latest" + echo "DEBUG: DOCKER_TAGS=${DOCKER_TAGS}" + echo DOCKER_TAGS="${DOCKER_TAGS}" >> $GITHUB_OUTPUT + + # this is the CLI image with the Linux binary for each + # arch that was downloaded in ./dist/ + - name: Build & Push Multi-Platform CLI Container Image to Hub + uses: docker/build-push-action@v3 + with: + builder: ${{ steps.buildx.outputs.name }} + context: ${{ github.workspace }}/ + file: ${{ github.workspace }}/docker-images/zrok/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.tagprep_cli.outputs.DOCKER_TAGS }} + build-args: | + DOCKER_BUILD_DIR=./docker-images/zrok + ARTIFACTS_DIR=./dist + push: true + + # - name: Set Up Container Image Tags for zrok Controller Container + # env: + # RELEASE_REPO: openziti/zrok-controller + # ZROK_VERSION: ${{ steps.semver.outputs.zrok_semver }} + # id: tagprep_ctrl + # run: | + # DOCKER_TAGS="" + # DOCKER_TAGS="${RELEASE_REPO}:${ZROK_VERSION},${RELEASE_REPO}:latest" + # echo "DEBUG: DOCKER_TAGS=${DOCKER_TAGS}" + # echo DOCKER_TAGS="${DOCKER_TAGS}" >> $GITHUB_OUTPUT + + # # This is a use-case image based on the minimal CLI image. It needs the + # # ZROK_VERSION env var so it can build from the versioned image that + # # we pushed in the prior step. + # - name: Build & Push Multi-Platform Controller Container Image to Hub + # uses: docker/build-push-action@v3 + # with: + # builder: ${{ steps.buildx.outputs.name }} + # context: ${{ github.workspace }}/docker-images/zrok-controller/ + # platforms: linux/amd64,linux/arm64 + # tags: ${{ steps.tagprep_ctrl.outputs.DOCKER_TAGS }} + # build-args: | + # ZROK_VERSION=${{ env.ZROK_VERSION }} + # push: true + + # - name: Set Up Container Image Tags for zrok Frontend Container + # env: + # RELEASE_REPO: openziti/zrok-frontend + # ZROK_VERSION: ${{ steps.semver.outputs.zrok_semver }} + # id: tagprep_frontend + # run: | + # DOCKER_TAGS="" + # DOCKER_TAGS="${RELEASE_REPO}:${ZROK_VERSION},${RELEASE_REPO}:latest" + # echo "DEBUG: DOCKER_TAGS=${DOCKER_TAGS}" + # echo DOCKER_TAGS="${DOCKER_TAGS}" >> $GITHUB_OUTPUT + + # - name: Build & Push Multi-Platform Frontend Container Image to Hub + # uses: docker/build-push-action@v3 + # with: + # builder: ${{ steps.buildx.outputs.name }} + # context: ${{ github.workspace }}/docker-images/zrok-frontend/ + # platforms: linux/amd64,linux/arm64 + # tags: ${{ steps.tagprep_frontend.outputs.DOCKER_TAGS }} + # build-args: | + # ZROK_VERSION=${{ env.ZROK_VERSION }} + # push: true + + # - name: Set Up Container Image Tags for zrok Share Container + # env: + # RELEASE_REPO: openziti/zrok-share + # ZROK_VERSION: ${{ steps.semver.outputs.zrok_semver }} + # id: tagprep_share + # run: | + # DOCKER_TAGS="" + # DOCKER_TAGS="${RELEASE_REPO}:${ZROK_VERSION},${RELEASE_REPO}:latest" + # echo "DEBUG: DOCKER_TAGS=${DOCKER_TAGS}" + # echo DOCKER_TAGS="${DOCKER_TAGS}" >> $GITHUB_OUTPUT + + # - name: Build & Push Multi-Platform zrok Share Container Image to Hub + # uses: docker/build-push-action@v3 + # with: + # builder: ${{ steps.buildx.outputs.name }} + # context: ${{ github.workspace }}/docker-images/zrok-share/ + # platforms: linux/amd64,linux/arm64 + # tags: ${{ steps.tagprep_share.outputs.DOCKER_TAGS }} + # build-args: | + # ZROK_VERSION=${{ env.ZROK_VERSION }} + # push: true + + # - name: Set Up Container Image Tags for zrok Access Container + # env: + # RELEASE_REPO: openziti/zrok-access + # ZROK_VERSION: ${{ steps.semver.outputs.zrok_semver }} + # id: tagprep_access + # run: | + # DOCKER_TAGS="" + # DOCKER_TAGS="${RELEASE_REPO}:${ZROK_VERSION},${RELEASE_REPO}:latest" + # echo "DEBUG: DOCKER_TAGS=${DOCKER_TAGS}" + # echo DOCKER_TAGS="${DOCKER_TAGS}" >> $GITHUB_OUTPUT + + # - name: Build & Push Multi-Platform zrok Access Container Image to Hub + # uses: docker/build-push-action@v3 + # with: + # builder: ${{ steps.buildx.outputs.name }} + # context: ${{ github.workspace }}/docker-images/zrok-access/ + # platforms: linux/amd64,linux/arm64 + # tags: ${{ steps.tagprep_access.outputs.DOCKER_TAGS }} + # build-args: | + # ZROK_VERSION=${{ env.ZROK_VERSION }} + # push: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 73dd6911..33703a33 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,8 +5,12 @@ on: tags: - 'v*.*.*' +# grant write permission to GITHUB_TOKEN for goreleaser +permissions: + contents: write + jobs: - build-linux: + build-linux-amd64: runs-on: ubuntu-20.04 steps: - run: sudo apt-get install gcc-multilib g++-multilib @@ -47,6 +51,47 @@ jobs: name: release-builds path: ./dist/*.gz + build-linux-arm64: + runs-on: ubuntu-20.04 + steps: + - run: sudo apt-get install gcc-aarch64-linux-gnu + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - run: git fetch --force --tags + + - uses: actions/setup-go@v3 + with: + go-version: '>=1.19.3' + cache: true + + - uses: actions/setup-node@v3 + with: + node-version: 16.x + + - run: npm install + working-directory: ui + + - run: npm run build + working-directory: ui + env: + CI: "" + + - uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --skip-publish --config .goreleaser-linux-arm64.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/upload-artifact@v3 + with: + name: release-builds + path: ./dist/*.gz + build-linux-arm: runs-on: ubuntu-20.04 steps: @@ -79,7 +124,7 @@ jobs: with: distribution: goreleaser version: latest - args: release --skip-publish --config .goreleaser-linux-arm.yml + args: release --skip-publish --config .goreleaser-linux-armhf.yml env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -181,7 +226,7 @@ jobs: path: ./dist/*.gz publish-release: - needs: [build-linux, build-linux-arm, build-darwin, build-windows] + needs: [build-linux-amd64, build-linux-arm, build-linux-arm64, build-darwin, build-windows] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -202,4 +247,4 @@ jobs: with: args: release --config .goreleaser-release.yml env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 8426cb6b..8d932fca 100644 --- a/.gitignore +++ b/.gitignore @@ -6,10 +6,10 @@ automated-release-build etc/dev.yml # Dependencies -/node_modules +/node_modules/ -# Production -/build +# Artifacts +/dist/ # Generated files .docusaurus diff --git a/.goreleaser-linux-arm64.yml b/.goreleaser-linux-arm64.yml new file mode 100644 index 00000000..095cda28 --- /dev/null +++ b/.goreleaser-linux-arm64.yml @@ -0,0 +1,15 @@ +builds: +- id: zrok-armv8 + main: ./cmd/zrok + binary: zrok + ldflags: "-s -w -X github.com/openziti/zrok/build.Version={{.Tag}} -X github.com/openziti/zrok/build.Hash={{.ShortCommit}}" + env: + - CC=aarch64-linux-gnu-gcc + - CGO_ENABLED=1 + - CC_FOR_TARGET=gcc-aarch64-linux-gnu + goos: + - linux + goarch: + - arm64 + goarm: + - 8 diff --git a/.goreleaser-linux-arm.yml b/.goreleaser-linux-armhf.yml similarity index 100% rename from .goreleaser-linux-arm.yml rename to .goreleaser-linux-armhf.yml diff --git a/.goreleaser-linux.yml b/.goreleaser-linux.yml index 2520c19f..a5ba3a63 100644 --- a/.goreleaser-linux.yml +++ b/.goreleaser-linux.yml @@ -7,4 +7,4 @@ builds: goos: - linux goarch: - - amd64 \ No newline at end of file + - amd64 diff --git a/docker-images/zrok/Dockerfile b/docker-images/zrok/Dockerfile new file mode 100644 index 00000000..49e04206 --- /dev/null +++ b/docker-images/zrok/Dockerfile @@ -0,0 +1,31 @@ +# this builds docker.io/openziti/zrok +FROM registry.access.redhat.com/ubi8/ubi-minimal +# This build stage grabs artifacts that are copied into the final image. +# It uses the same base as the final image to maximize docker cache hits. + +ARG ARTIFACTS_DIR=./dist +ARG DOCKER_BUILD_DIR=. +# e.g. linux +ARG TARGETOS +# e.g. arm64 +ARG TARGETARCH + +### Required OpenShift Labels +LABEL name="openziti/zrok" \ + maintainer="support@zrok.io" \ + vendor="NetFoundry" \ + summary="Run the zrok CLI" \ + description="Run the zrok CLI" + +USER root + +### add licenses to this directory +RUN mkdir -m0755 /licenses +COPY ./LICENSE /licenses/apache.txt + +RUN mkdir -p /usr/local/bin +COPY ${ARTIFACTS_DIR}/${TARGETARCH}/${TARGETOS}/zrok /usr/local/bin/ +RUN chmod 0755 /usr/local/bin/zrok + +USER nobody +ENTRYPOINT [ "zrok" ]