-
Notifications
You must be signed in to change notification settings - Fork 761
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9676 from everpcpc/feat-minio
ci: support setup minio storage & external s3 storage in docker image
- Loading branch information
Showing
6 changed files
with
178 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,78 @@ | ||
# Multi-architecture Docker image support | ||
# Databend All-in-One Docker Image | ||
|
||
Support cross platform docker image build | ||
Support Platform: `linux/amd64`, `linux/arm64` | ||
|
||
## How to use | ||
|
||
## Install docker ![Buildkit](https://github.com/moby/buildkit) | ||
## Available Enviroment Variables | ||
|
||
For macOS | ||
* DATABEND_QUERY_CONFIG_FILE | ||
* DATABEND_QUERY_DEFAULT_USER | ||
* DATABEND_QUERY_DEFAULT_PASSWORD | ||
* DATABEND_QUERY_STORAGE_TYPE | ||
|
||
```bash | ||
brew install buildkit | ||
``` | ||
* AWS_S3_ENDPOINT | ||
* AWS_S3_PRESIGNED_ENDPOINT | ||
* AWS_S3_BUCKET | ||
* AWS_ACCESS_KEY_ID | ||
* AWS_SECRET_ACCESS_KEY | ||
|
||
For linux | ||
* MINIO_ENABLED | ||
|
||
```bash | ||
docker run --name buildkit -d --privileged -p 1234:1234 moby/buildkit --addr tcp://0.0.0.0:1234 | ||
export BUILDKIT_HOST=tcp://0.0.0.0:1234 | ||
docker cp buildkit:/usr/bin/buildctl /usr/local/bin/ | ||
buildctl build --help | ||
``` | ||
|
||
## Check on available platforms given your host machine | ||
## How to use | ||
|
||
|
||
```bash | ||
docker run --privileged --rm tonistiigi/binfmt --install all | ||
### Run default config with fs backend | ||
``` | ||
docker run -p 8000:8000 datafuselabs/databend | ||
``` | ||
|
||
## Build and push container for supported platforms | ||
|
||
### initialize host networking | ||
### Run with MinIO as backend | ||
``` | ||
docker run \ | ||
-p 8000:8000 \ | ||
-p 9000:9000 \ | ||
-e MINIO_ENABLED=true \ | ||
datafuselabs/databend | ||
``` | ||
|
||
```bash | ||
docker buildx create --name host --use --buildkitd-flags '--allow-insecure-entitlement network.host' | ||
### Adding built-in query user | ||
``` | ||
docker run \ | ||
-p 8000:8000 \ | ||
-e DATABEND_QUERY_DEFAULT_USER=databend \ | ||
-e DATABEND_QUERY_DEFAULT_PASSWORD=databend \ | ||
datafuselabs/databend | ||
``` | ||
|
||
### update qemu static link | ||
### Run with external S3 service | ||
|
||
```bash | ||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
``` | ||
docker run \ | ||
-p 8000:8000 \ | ||
-e DATABEND_QUERY_STORAGE_TYPE=s3 \ | ||
-e AWS_S3_ENDPOINT="http://some_s3_endpoint \ | ||
-e AWS_S3_BUCKET=some_bucket \ | ||
-e AWS_ACCESS_KEY_ID=some_key \ | ||
-e AWS_SECRET_ACCESS_KEY=some_secret \ | ||
datafuselabs/databend | ||
``` | ||
|
||
### build with given buildx builder | ||
|
||
return to databend root directory | ||
### Run with persistent local storage & logs | ||
``` | ||
docker run \ | ||
-p 8000:8000 \ | ||
-v meta_storage_dir:/var/lib/databend/meta \ | ||
-v query_storage_dir:/var/lib/databend/query \ | ||
-v log_dir:/var/log/databend \ | ||
datafuselabs/databend | ||
``` | ||
|
||
```bash | ||
make dockerx PLATFORM=<platform your host machine supports> | ||
``` | ||
### Run with self managed query config | ||
``` | ||
docker run \ | ||
-p 8000:8000 \ | ||
-e DATABEND_QUERY_CONFIG_FILE=/etc/databend/mine.toml \ | ||
-v query_config_file:/etc/databend/mine.toml \ | ||
datafuselabs/databend | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,114 @@ | ||
#!/bin/bash | ||
|
||
# DATABEND_DEFAULT_USER="${DATABEND_DEFAULT_USER:-databend}" | ||
# DATABEND_DEFAULT_PASSWORD="${DATABEND_DEFAULT_PASSWORD:-databend}" | ||
PROCESSES=() | ||
|
||
/databend-meta --single &>/tmp/databend-meta.log & | ||
P1=$! | ||
mkdir -p /var/log/databend | ||
mkdir -p /var/lib/databend/meta | ||
mkdir -p /var/lib/databend/query | ||
|
||
# TODO: add health check to remove the race condition issue during databend-query bootstrap | ||
databend-meta \ | ||
--log-file-dir /var/log/databend \ | ||
--log-stderr-level WARN \ | ||
--raft-dir /var/lib/databend/meta \ | ||
--single &>/tmp/std-meta.log & | ||
PROCESSES+=($!) | ||
# wait for meta to be ready | ||
sleep 1 | ||
|
||
if [ -n "$DATABEND_DEFAULT_USER" ] && [ -n "$DATABEND_DEFAULT_PASSWORD" ]; then | ||
DOUBLE_SHA1_PASSWORD=$(echo -n "$DATABEND_DEFAULT_PASSWORD" | sha1sum | cut -d' ' -f1 | xxd -r -p | sha1sum | cut -d' ' -f1) | ||
cat <<EOF >>databend-query.toml | ||
function setup_query_default_user { | ||
if [ -n "$DATABEND_QUERY_DEFAULT_USER" ] && [ -n "$DATABEND_QUERY_DEFAULT_PASSWORD" ]; then | ||
DOUBLE_SHA1_PASSWORD=$(echo -n "$DATABEND_QUERY_DEFAULT_PASSWORD" | sha1sum | cut -d' ' -f1 | xxd -r -p | sha1sum | cut -d' ' -f1) | ||
cat <<EOF >>"$QUERY_CONFIG_FILE" | ||
[[query.users]] | ||
name = "$DATABEND_DEFAULT_USER" | ||
name = "$DATABEND_QUERY_DEFAULT_USER" | ||
auth_type = "double_sha1_password" | ||
auth_string = "$DOUBLE_SHA1_PASSWORD" | ||
EOF | ||
fi | ||
} | ||
|
||
function setup_minio { | ||
echo "==> Downloading MinIO server..." | ||
arch=$(uname -m) | ||
case $arch in | ||
"x86_64") | ||
platform="amd64" | ||
;; | ||
"aarch64") | ||
platform="arm64" | ||
;; | ||
*) | ||
echo "==> Unsupported architecture: $arch" | ||
exit 1 | ||
;; | ||
esac | ||
curl -sSLo /usr/bin/minio "https://dl.min.io/server/minio/release/linux-${platform}/minio" | ||
echo "==> MinIO server downloaded." | ||
chmod +x /usr/bin/minio | ||
mkdir -p /var/lib/minio | ||
# make sure the bucket exists | ||
mkdir -p "/var/lib/minio/$AWS_S3_BUCKET" | ||
MINIO_ROOT_USER="$AWS_ACCESS_KEY_ID" MINIO_ROOT_PASSWORD="$AWS_SECRET_ACCESS_KEY" minio server /var/lib/minio &>/tmp/std-minio.log & | ||
PROCESSES+=($!) | ||
# wait for minio to be ready | ||
sleep 1 | ||
} | ||
|
||
function setup_query_storage { | ||
QUERY_STORAGE_TYPE=${QUERY_STORAGE_TYPE:-"fs"} | ||
if [[ -n $MINIO_ENABLED ]]; then | ||
# force to use s3 storage when minio is enabled | ||
QUERY_STORAGE_TYPE="s3" | ||
AWS_S3_BUCKET=${AWS_S3_BUCKET:-"databend"} | ||
AWS_S3_ENDPOINT=${AWS_S3_ENDPOINT:-"http://0.0.0.0:9000"} | ||
AWS_S3_PRESIGNED_ENDPOINT=${AWS_S3_PRESIGNED_ENDPOINT:-"http://localhost:9000"} | ||
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID:-"minio"} | ||
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY:-"miniostorage"} | ||
setup_minio | ||
fi | ||
case $QUERY_STORAGE_TYPE in | ||
"fs") | ||
mkdir -p /var/lib/databend/query | ||
cat <<EOF >>"$QUERY_CONFIG_FILE" | ||
[storage] | ||
type = "fs" | ||
[storage.fs] | ||
data_path = "/var/lib/databend/query" | ||
EOF | ||
;; | ||
"s3") | ||
cat <<EOF >>"$QUERY_CONFIG_FILE" | ||
[storage] | ||
type = "s3" | ||
[storage.s3] | ||
bucket = "$AWS_S3_BUCKET" | ||
endpoint_url = "$AWS_S3_ENDPOINT" | ||
access_key_id = "$AWS_ACCESS_KEY_ID" | ||
secret_access_key = "$AWS_SECRET_ACCESS_KEY" | ||
presign_endpoint_url = "$AWS_S3_PRESIGNED_ENDPOINT" | ||
EOF | ||
;; | ||
|
||
*) | ||
echo "==> Unsupported storage type: $QUERY_STORAGE_TYPE" | ||
exit 1 | ||
;; | ||
esac | ||
} | ||
|
||
if [ -z "$QUERY_CONFIG_FILE" ]; then | ||
QUERY_CONFIG_FILE="/etc/databend/query.toml" | ||
echo "==> QUERY_CONFIG_FILE is not set, using default: $QUERY_CONFIG_FILE" | ||
setup_query_default_user | ||
setup_query_storage | ||
fi | ||
|
||
/databend-query -c databend-query.toml &>/tmp/databend-query.log & | ||
P2=$! | ||
databend-query -c "$QUERY_CONFIG_FILE" &>/tmp/std-query.log & | ||
PROCESSES+=($!) | ||
# wait for query to be ready | ||
sleep 1 | ||
|
||
tail -f /tmp/databend-query.log & | ||
P3=$! | ||
tail -n +1 -F /tmp/std-*.log & | ||
PROCESSES+=($!) | ||
|
||
tail -f /tmp/databend-meta.log & | ||
P4=$! | ||
wait $P1 $P2 $P3 $P4 | ||
wait "${PROCESSES[@]}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
daca9d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
databend – ./
databend.vercel.app
databend-databend.vercel.app
databend.rs
databend-git-main-databend.vercel.app