From d70db4759eba81765ff3e847ba895acfafb06f1d Mon Sep 17 00:00:00 2001 From: Alexandre Dutra Date: Fri, 28 Jun 2024 08:06:57 +0200 Subject: [PATCH] Nessie CLI: publish Docker images (#8935) --- .github/docker-sync/regsync.yml | 7 ++++ .github/workflows/ci.yml | 28 ++++++++++++++ .github/workflows/release-publish.yml | 7 ++++ .github/workflows/snapshot-publish.yml | 5 +++ CHANGELOG.md | 4 ++ docker/cli/docker-compose.yml | 45 +++++++++++++++++++++++ site/docs/downloads/index.md | 17 +++++++++ site/in-dev/cli.md | 26 ++++++------- site/in-dev/index-release.md | 17 +++++++++ site/in-dev/index.md | 21 +++++++++++ tools/dockerbuild/build-push-images.sh | 7 +++- tools/dockerbuild/docker/Dockerfile-cli | 15 ++++++++ tools/releases/create-gh-release-notes.sh | 3 ++ 13 files changed, 185 insertions(+), 17 deletions(-) create mode 100644 docker/cli/docker-compose.yml create mode 100644 tools/dockerbuild/docker/Dockerfile-cli diff --git a/.github/docker-sync/regsync.yml b/.github/docker-sync/regsync.yml index 20319802817..73476fb1ad1 100644 --- a/.github/docker-sync/regsync.yml +++ b/.github/docker-sync/regsync.yml @@ -33,3 +33,10 @@ sync: - source: ghcr.io/projectnessie/nessie-server-admin target: quay.io/projectnessie/nessie-server-admin type: repository + # CLI + - source: ghcr.io/projectnessie/nessie-cli-unstable + target: quay.io/projectnessie/nessie-cli-unstable + type: repository + - source: ghcr.io/projectnessie/nessie-cli + target: quay.io/projectnessie/nessie-cli + type: repository diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1df04b6cfc5..873abbe0307 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -749,6 +749,7 @@ jobs: echo "DOCKER_IMAGE=${DOCKER_REGISTRY}:5000/nessie-testing" >> ${GITHUB_ENV} echo "DOCKER_GC_IMAGE=${DOCKER_REGISTRY}:5000/nessie-gc-testing" >> ${GITHUB_ENV} echo "DOCKER_SERVER_ADMIN_IMAGE=${DOCKER_REGISTRY}:5000/nessie-server-admin-testing" >> ${GITHUB_ENV} + echo "DOCKER_CLI_IMAGE=${DOCKER_REGISTRY}:5000/nessie-cli-testing" >> ${GITHUB_ENV} - name: Prepare Gradle build cache uses: ./.github/actions/ci-incr-build-cache-prepare @@ -773,6 +774,12 @@ jobs: -d "Dockerfile-admintool" \ ${DOCKER_SERVER_ADMIN_IMAGE} + tools/dockerbuild/build-push-images.sh \ + -g ":nessie-cli" \ + -p "cli/cli" \ + -d "Dockerfile-cli" \ + ${DOCKER_CLI_IMAGE} + - name: Cleanup buildx run: | docker buildx use default @@ -792,6 +799,10 @@ jobs: docker pull ${DOCKER_SERVER_ADMIN_IMAGE}:latest-java docker pull ${DOCKER_SERVER_ADMIN_IMAGE}:${DOCKER_VERSION} docker pull ${DOCKER_SERVER_ADMIN_IMAGE}:${DOCKER_VERSION}-java + docker pull ${DOCKER_CLI_IMAGE}:latest + docker pull ${DOCKER_CLI_IMAGE}:latest-java + docker pull ${DOCKER_CLI_IMAGE}:${DOCKER_VERSION} + docker pull ${DOCKER_CLI_IMAGE}:${DOCKER_VERSION}-java cat <> $GITHUB_STEP_SUMMARY ## Docker images @@ -858,6 +869,23 @@ jobs: exit 1 fi + - name: Check if CLI Docker Java image works + run: | + if docker run --rm --name nessie-cli ${DOCKER_CLI_IMAGE}:latest-java --help | grep -q "Usage: nessie-cli.jar"; then + echo "## CLI Java Docker image smoke test: PASSED" >> $GITHUB_STEP_SUMMARY + echo "CLI Java Docker image smoke test: PASSED" + else + echo "CLI Java Docker image smoke test: FAILED" > /dev/stderr + cat <> $GITHUB_STEP_SUMMARY + ## CLI Java Docker image FAILED + + \`\`\` + $(docker logs nessie-cli) + \`\`\` + ! + exit 1 + fi + - name: Run chart-testing (list-changed) run: | ct list-changed --target-branch ${{ github.event.repository.default_branch }} diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 38fe6c15904..85c156bbdc3 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -212,6 +212,13 @@ jobs: -d "Dockerfile-admintool" \ ghcr.io/projectnessie/nessie-server-admin + - name: Publish Nessie CLI + run: | + tools/dockerbuild/build-push-images.sh \ + -g ":nessie-cli" \ + -p "cli/cli" \ + -d "Dockerfile-cli" \ + ghcr.io/projectnessie/nessie-cli publish-helm: name: Publish Helm Chart diff --git a/.github/workflows/snapshot-publish.yml b/.github/workflows/snapshot-publish.yml index f153998a471..c3c33e46aa1 100644 --- a/.github/workflows/snapshot-publish.yml +++ b/.github/workflows/snapshot-publish.yml @@ -105,3 +105,8 @@ jobs: -p "tools/server-admin" \ -d "Dockerfile-admintool" \ ghcr.io/projectnessie/nessie-server-admin-unstable + tools/dockerbuild/build-push-images.sh \ + -g ":nessie-cli" \ + -p "cli/cli" \ + -d "Dockerfile-cli" \ + ghcr.io/projectnessie/nessie-cli-unstable diff --git a/CHANGELOG.md b/CHANGELOG.md index 3154ad045ec..784246ed1c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ as necessary. Empty sections will not end in the release notes. ### New Features +- Nessie CLI now has its own Docker images. Running Nessie CLI is now as simple as: `docker run -it + ghcr.io/projectnessie/nessie-cli`. Read more about it + [here](https://projectnessie.org/nessie-latest/cli/). + ### Changes ### Deprecations diff --git a/docker/cli/docker-compose.yml b/docker/cli/docker-compose.yml new file mode 100644 index 00000000000..59e918101ec --- /dev/null +++ b/docker/cli/docker-compose.yml @@ -0,0 +1,45 @@ +# +# Copyright (C) 2024 Dremio +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# In order to have an interactive shell for Nessie CLI, execute the following command: +# docker-compose run nessie-cli + +services: + + nessie: + image: ghcr.io/projectnessie/nessie:0.91.2 + ports: + # API port + - "19120:19120" + # Management port (metrics and health checks) + - "9000:9000" + environment: + - nessie.version.store.type=IN_MEMORY # Ephemeral storage, data is lost during reset. + healthcheck: + test: "exec 3<>/dev/tcp/localhost/9000 && echo -e 'GET /q/health HTTP/1.1\\r\\nHost: localhost\\r\\nConnection: close\\r\\n\\r\\n' >&3 && cat <&3 | grep -q '200 OK'" + interval: 5s + timeout: 2s + retries: 15 + + nessie-cli: + image: ghcr.io/projectnessie/nessie-cli:0.91.2 + stdin_open: true # docker run -i + tty: true # docker run -t + depends_on: + nessie: + condition: service_healthy + command: + - --uri=http://nessie:19120/api/v2 diff --git a/site/docs/downloads/index.md b/site/docs/downloads/index.md index 7e5d0462db9..7a46629f21b 100644 --- a/site/docs/downloads/index.md +++ b/site/docs/downloads/index.md @@ -62,6 +62,23 @@ java -jar nessie-quarkus-{{ versions.nessie }}-runner.jar [Nessie CLI](/nessie-latest/cli/) is both a command-line interface but primarily a REPL. +### Docker image + +Docker images are multiplatform images for amd64, arm64, ppc64le, s390x. + +=== "GitHub Container Registry" + [GitHub Container Registry](https://github.com/projectnessie/nessie/pkgs/container/nessie-cli) + ```bash + docker pull ghcr.io/projectnessie/nessie-cli:{{ versions.nessie }} + docker run -it ghcr.io/projectnessie/nessie-cli:{{ versions.nessie }} + ``` +=== "Quay.io" + [quay.io](https://quay.io/repository/projectnessie/nessie-cli?tab=tags) + ```bash + docker pull quay.io/projectnessie/nessie-cli:{{ versions.nessie }} + docker run -it quay.io/projectnessie/nessie-cli:{{ versions.nessie }} + ``` + ### Standalone uber jar Requires Java 11 or newer. diff --git a/site/in-dev/cli.md b/site/in-dev/cli.md index fdc7ad1fe32..d820c35af8e 100644 --- a/site/in-dev/cli.md +++ b/site/in-dev/cli.md @@ -5,9 +5,7 @@ title: "Nessie CLI" # Nessie CLI The Nessie CLI is an easy way to get started with Nessie. It supports multiple branch -and tag management capabilities. This is installed as a standalone uber jar from the -[Nessie download page](../downloads/index.md) or the -[releases page on GitHub](https://github.com/projectnessie/nessie/releases/). +and tag management capabilities. Nessie CLI is designed to be usable as an interactive REPL supporting auto-completion, highlighting where appropriate and has built-in help. Long outputs, like a commit log, @@ -17,23 +15,21 @@ are automatically paged like the Unix `less` command. ![Nessie CLI](../img/cli-intro.png) -## Usage +## Installation -Nessie CLI requires Java 11. +Nessie CLI is available as a standalone uber jar, or as a Docker image. See download options in +the [Nessie download page](../downloads/index.md) or in the [releases page on +GitHub](https://github.com/projectnessie/nessie/releases/). -```bash -java -jar nessie-cli-.jar -``` +## Usage -!!! tip - Use `CONNECT TO http://127.0.0.1:19120/iceberg` to connect to a locally running Nessie - instance with Iceberg REST. Use `CONNECT TO http://127.0.0.1:19120/api/v2` for Nessie's - native REST API. +Use `CONNECT TO http://127.0.0.1:19120/iceberg` to connect to a locally running Nessie instance with +Iceberg REST. Use `CONNECT TO http://127.0.0.1:19120/api/v2` for Nessie's native REST API. - Use `CONNECT TO https://app.dremio.cloud/repositories//api/v2` to - connect to your Dremio cloud instance using Nessie's native REST API. +Use `CONNECT TO https://app.dremio.cloud/repositories//api/v2` to connect to your Dremio +cloud instance using Nessie's native REST API. - See [`CONNECT` statement](#connect) below. +See [`CONNECT` statement](#connect) below. ### Command line options diff --git a/site/in-dev/index-release.md b/site/in-dev/index-release.md index 3ea6ce62555..aa80ba1db17 100644 --- a/site/in-dev/index-release.md +++ b/site/in-dev/index-release.md @@ -61,6 +61,23 @@ java -jar nessie-quarkus-::NESSIE_VERSION::-runner.jar [Nessie CLI](cli.md) is both a command-line interface but primarily a REPL. +### Docker image + +Docker images are multiplatform images for amd64, arm64, ppc64le, s390x. + +=== "GitHub Container Registry" + [GitHub Container Registry](https://github.com/projectnessie/nessie/pkgs/container/nessie-cli) + ```bash + docker pull ghcr.io/projectnessie/nessie-cli:::NESSIE_VERSION:: + docker run -it ghcr.io/projectnessie/nessie-cli:::NESSIE_VERSION:: + ``` +=== "Quay.io" + [quay.io](https://quay.io/repository/projectnessie/nessie-cli?tab=tags) + ```bash + docker pull quay.io/projectnessie/nessie-cli:::NESSIE_VERSION:: + docker run -it quay.io/projectnessie/nessie-cli:::NESSIE_VERSION:: + ``` + ### Standalone uber jar Requires Java 11 or newer. diff --git a/site/in-dev/index.md b/site/in-dev/index.md index 17a9592d19b..0bf537b0096 100644 --- a/site/in-dev/index.md +++ b/site/in-dev/index.md @@ -33,6 +33,27 @@ Docker images are multiplatform images for amd64, arm64, ppc64le, s390x. docker run -p 19120:19120 -p 9000:9000 quay.io/projectnessie/nessie-unstable ``` +## Nessie CLI unstable/nightly + +### Docker image + +Docker images are multiplatform images for amd64, arm64, ppc64le, s390x. + +**The image tags are updated twice per day during weekdays.** + +=== "GitHub Container Registry" + [GitHub Container Registry](https://github.com/projectnessie/nessie/pkgs/container/nessie-cli-unstable) + ```bash + docker pull ghcr.io/projectnessie/nessie-cli-unstable + docker run -it ghcr.io/projectnessie/nessie-cli-unstable + ``` +=== "Quay.io" + [quay.io](https://quay.io/repository/projectnessie/nessie-cli-unstable?tab=tags) + ```bash + docker pull quay.io/projectnessie/nessie-cli-unstable + docker run -it quay.io/projectnessie/nessie-cli-unstable + ``` + ## GC Tool unstable/nightly [Nessie GC](/nessie-nightly/gc/) allows mark and sweep data files based on flexible diff --git a/tools/dockerbuild/build-push-images.sh b/tools/dockerbuild/build-push-images.sh index 8449e0f017c..fb538e52499 100755 --- a/tools/dockerbuild/build-push-images.sh +++ b/tools/dockerbuild/build-push-images.sh @@ -59,6 +59,7 @@ function usage() { $0 --dockerfile Dockerfile-server --gradle-project :nessie-quarkus --project-dir servers/quarkus-server nessie-unstable $0 --dockerfile Dockerfile-gctool --gradle-project :nessie-gc-tool --project-dir gc/gc-tool nessie-gc-unstable $0 --dockerfile Dockerfile-admintool --gradle-project :nessie-server-admin-tool --project-dir tools/server-admin nessie-admin-unstable + $0 --dockerfile Dockerfile-cli --gradle-project :nessie-cli --project-dir cli/cli nessie-cli-unstable ! } @@ -127,8 +128,8 @@ cd "$BASE_DIR" # gh_group "Prepare Docker image name and tag base" -IMAGE_TAG="$(cat version.txt)" -IMAGE_TAG_BASE="${IMAGE_TAG%-SNAPSHOT}" +VERSION="$(cat version.txt)" +IMAGE_TAG_BASE="${VERSION%-SNAPSHOT}" echo "Image name: ${IMAGE_NAME}" echo "Tag base: ${IMAGE_TAG_BASE}" gh_endgroup @@ -163,6 +164,7 @@ if [[ ${LOCAL} == 1 ]] ; then --file "${BASE_DIR}/tools/dockerbuild/docker/${DOCKERFILE}" \ --tag "${IMAGE_NAME}:latest" \ --tag "${IMAGE_NAME}:${IMAGE_TAG_BASE}" \ + --build-arg VERSION="${VERSION}" \ "${BASE_DIR}/${PROJECT_DIR}" gh_endgroup else @@ -176,6 +178,7 @@ else --tag "${IMAGE_NAME}:latest-java" \ --tag "${IMAGE_NAME}:${IMAGE_TAG_BASE}" \ --tag "${IMAGE_NAME}:${IMAGE_TAG_BASE}-java" \ + --build-arg VERSION="${VERSION}" \ "${BASE_DIR}/${PROJECT_DIR}" \ --push \ --provenance=false --sbom=false \ diff --git a/tools/dockerbuild/docker/Dockerfile-cli b/tools/dockerbuild/docker/Dockerfile-cli new file mode 100644 index 00000000000..300f41f4d51 --- /dev/null +++ b/tools/dockerbuild/docker/Dockerfile-cli @@ -0,0 +1,15 @@ +FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.20-2 + +LABEL org.opencontainers.image.source=https://github.com/projectnessie/nessie +LABEL org.opencontainers.image.description="Projectnessie CLI" +LABEL org.opencontainers.image.licenses=Apache-2.0 + +ARG VERSION + +ENV LANGUAGE='en_US:en' + +COPY --chown=185 build/libs/nessie-cli-$VERSION.jar /nessie-cli.jar + +USER 185 + +ENTRYPOINT [ "java", "-jar", "/nessie-cli.jar" ] diff --git a/tools/releases/create-gh-release-notes.sh b/tools/releases/create-gh-release-notes.sh index 0ac5c9df575..ccca61c154b 100755 --- a/tools/releases/create-gh-release-notes.sh +++ b/tools/releases/create-gh-release-notes.sh @@ -84,6 +84,7 @@ NUM_COMMITS=$(git log --format='format:%h' ${LAST_TAG}..HEAD^1 | wc -l | xargs) git log --perl-regexp --author '^(?!.*renovate|.*nessie-release-workflow).*$' --format='format:* %s' ${LAST_TAG}..${GIT_TAG} | grep -v '^\* \[release\] .*$' > ./release-log +Q_CLI_URL="https://github.com/projectnessie/nessie/releases/download/nessie-${RELEASE_VERSION}/nessie-cli-${RELEASE_VERSION}.jar" Q_GC_TOOL_URL="https://github.com/projectnessie/nessie/releases/download/nessie-${RELEASE_VERSION}/nessie-gc-${RELEASE_VERSION}.jar" Q_UBER_URL="https://github.com/projectnessie/nessie/releases/download/nessie-${RELEASE_VERSION}/nessie-quarkus-${RELEASE_VERSION}-runner.jar" Q_SERVER_ADMIN_URL="https://github.com/projectnessie/nessie/releases/download/nessie-${RELEASE_VERSION}/nessie-server-admin-tool-${RELEASE_VERSION}-runner.jar" @@ -106,6 +107,8 @@ wget ${Q_UBER_URL} java -jar nessie-quarkus-${RELEASE_VERSION}-runner.jar \`\`\` +Nessie CLI is attached as [\`nessie-cli-${RELEASE_VERSION}.jar\`](${Q_CLI_URL}), which is a standalone uber-jar file that runs on Java 11 or newer. Nessie CLI is also available as a Docker image: \`docker run --rm -it ghcr.io/projectnessie/nessie-cli:${RELEASE_VERSION}\`. + Nessie GC tool is attached as [\`nessie-gc-${RELEASE_VERSION}.jar\`](${Q_GC_TOOL_URL}), which is a standalone uber-jar file that runs on Java 11 or newer. Shell completion can be generated from the tool, check its \`help\` command. Nessie GC tool is also available as a Docker image: \`docker run --rm ghcr.io/projectnessie/nessie-gc:${RELEASE_VERSION} --help\`. Nessie Server Admin tool is attached as [\`nessie-server-admin-tool-${RELEASE_VERSION}-runner.jar\`](${Q_SERVER_ADMIN_URL}), which is a standalone uber-jar file that runs on Java 17 or newer. Shell completion can be generated from the tool, check its \`help\` command. Nessie Server Admin tool is also available as a Docker image: \`docker run --rm ghcr.io/projectnessie/nessie-server-admin:${RELEASE_VERSION} --help\`.