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
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
matrix:
features:
- actionlint
- clickhouse-client
- elixir-project
- google-cloud-cli
- node
Expand All @@ -37,6 +38,7 @@ jobs:
matrix:
features:
- actionlint
- clickhouse-client
- google-cloud-cli
- node
- postgresql-client
Expand Down
27 changes: 27 additions & 0 deletions src/clickhouse-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# clickhouse-client

Install `clickhouse-client`, the command-line client for [ClickHouse](https://clickhouse.com), from ClickHouse's signed `stable` apt repository.

## Usage

```json
"features": {
"ghcr.io/CargoSense/devcontainer-features/clickhouse-client:1": {}
}
```

## Options

| Option ID | Description | Type | Default Value |
|:----------|:------------------------------------------|:-------|:--------------|
| `version` | The clickhouse-client version to install. | string | `latest` |

A pinned version is a full package version such as `26.8.51.4`; `apt-cache madison clickhouse-client` lists them once the repository is added.

## Image size

The client ships inside `clickhouse-common-static`, the single ClickHouse binary, so the Feature adds about 600 MB to the image. ClickHouse publishes no smaller client-only package.

## OS Support

This Feature should work on recent versions of Debian/Ubuntu and Linux distributions using the [apt](https://wiki.debian.org/AptCLI) management tool.
21 changes: 21 additions & 0 deletions src/clickhouse-client/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "ClickHouse Client",
"id": "clickhouse-client",
"version": "1.0.0",
"description": "Install clickhouse-client, the command-line client for ClickHouse.",
"documentationURL": "https://github.com/CargoSense/devcontainer-features/tree/main/src/clickhouse-client",
"licenseURL": "https://github.com/CargoSense/devcontainer-features/blob/main/LICENSE",
"options": {
"version": {
"type": "string",
"proposals": [
"latest"
],
"default": "latest",
"description": "Select or enter a clickhouse-client version (e.g. 26.8.51.4)."
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
}
52 changes: 52 additions & 0 deletions src/clickhouse-client/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env sh

set -e

CLICKHOUSE_CLIENT_VERSION="${VERSION:-"latest"}"

if [ "$(id -u)" -ne 0 ]; then
printf 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi

curl_installed=""
gpg_installed=""

if ! type curl >/dev/null 2>&1; then
apt-get update --yes
apt-get install --no-install-recommends --yes curl ca-certificates

curl_installed="true"
fi

if ! type gpg >/dev/null 2>&1; then
apt-get update --yes
apt-get install --no-install-recommends --yes gpg

gpg_installed="true"
fi

# ClickHouse signs its deb repository with the key it publishes beside its rpm
# repository; https://clickhouse.com/docs/install/debian_ubuntu uses the same URL.
curl -fsSL https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key | gpg --dearmor --yes -o /usr/share/keyrings/clickhouse-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg arch=$(dpkg --print-architecture)] https://packages.clickhouse.com/deb stable main" > /etc/apt/sources.list.d/clickhouse.list

apt-get update --yes

if [ "${CLICKHOUSE_CLIENT_VERSION}" = "latest" ]; then
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes clickhouse-client
else
# clickhouse-client depends on exactly its own version of clickhouse-common-static,
# so a pinned client needs the matching common package pinned beside it.
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes \
clickhouse-client="${CLICKHOUSE_CLIENT_VERSION}" \
clickhouse-common-static="${CLICKHOUSE_CLIENT_VERSION}"
fi

if [ -n "${curl_installed}" ]; then
apt purge curl --autoremove --yes
fi

if [ -n "${gpg_installed}" ]; then
apt purge gpg --autoremove --yes
fi
14 changes: 14 additions & 0 deletions test/clickhouse-client/install-trixie-with-settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Feature-specific tests
check "version" bash -c "clickhouse-client --version | grep 26.8.51.4"
check "which clickhouse-client" bash -c "which clickhouse-client | grep /usr/bin/clickhouse-client"

# Report result
reportResults
14 changes: 14 additions & 0 deletions test/clickhouse-client/install-trixie.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Feature-specific tests
check "version" clickhouse-client --version
check "which clickhouse-client" bash -c "which clickhouse-client | grep /usr/bin/clickhouse-client"

# Report result
reportResults
19 changes: 19 additions & 0 deletions test/clickhouse-client/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"install-trixie": {
"image": "debian:trixie",
"features": {
"clickhouse-client": {
"version": "latest"
}
}
},

"install-trixie-with-settings": {
"image": "debian:trixie",
"features": {
"clickhouse-client": {
"version": "26.8.51.4"
}
}
}
}
14 changes: 14 additions & 0 deletions test/clickhouse-client/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
# shellcheck source=/dev/null
source dev-container-features-test-lib

# Feature-specific tests
check "version" clickhouse-client --version
check "which clickhouse-client" bash -c "which clickhouse-client | grep /usr/bin/clickhouse-client"

# Report result
reportResults
Loading