diff --git a/clickhouse/Dockerfile b/clickhouse/Dockerfile new file mode 100644 index 00000000000..4e841c04bbf --- /dev/null +++ b/clickhouse/Dockerfile @@ -0,0 +1,2 @@ +ARG BASE_IMAGE +FROM ${BASE_IMAGE} diff --git a/clickhouse/config.xml b/clickhouse/config.xml index 55cdbbd82b8..58ab86258ca 100644 --- a/clickhouse/config.xml +++ b/clickhouse/config.xml @@ -1,5 +1,10 @@ - + + + + information 1 diff --git a/docker-compose.yml b/docker-compose.yml index 6088257a38e..9c580377b4f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,8 @@ x-healthcheck-defaults: &healthcheck_defaults x-sentry-defaults: &sentry_defaults <<: *restart_policy image: sentry-self-hosted-local + # Set the platform to build for linux/arm64 when needed on Apple silicon Macs. + platform: ${DOCKER_PLATFORM:-} build: context: ./sentry args: @@ -190,7 +192,12 @@ services: test: ["CMD-SHELL", "nc -z localhost 9092"] clickhouse: <<: *restart_policy - image: "yandex/clickhouse-server:20.3.9.70" + image: clickhouse-self-hosted-local + build: + context: + ./clickhouse + args: + BASE_IMAGE: "${CLICKHOUSE_IMAGE:-}" ulimits: nofile: soft: 262144 diff --git a/install.sh b/install.sh index 8b4f063c064..efee0cdf32e 100755 --- a/install.sh +++ b/install.sh @@ -11,6 +11,7 @@ source "$(dirname $0)/install/_lib.sh" # does a `cd .../install/`, among other # Pre-flight. No impact yet. source parse-cli.sh +source detect-platform.sh source dc-detect-version.sh source error-handling.sh source check-latest-commit.sh diff --git a/install/check-minimum-requirements.sh b/install/check-minimum-requirements.sh index 61484d35efe..b88f36eb11b 100644 --- a/install/check-minimum-requirements.sh +++ b/install/check-minimum-requirements.sh @@ -6,6 +6,12 @@ source "$(dirname $0)/_min-requirements.sh" function ver () { echo "$@" | awk -F. '{ printf("%d%03d%03d", $1,$2,$3); }'; } DOCKER_VERSION=$(docker version --format '{{.Server.Version}}') + +if [[ -z "$DOCKER_VERSION" ]]; then + echo "FAIL: Unable to get docker version, is the docker daemon running?" + exit 1 +fi + if [[ "$(ver $DOCKER_VERSION)" -lt "$(ver $MIN_DOCKER_VERSION)" ]]; then echo "FAIL: Expected minimum docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION" exit 1 @@ -39,7 +45,7 @@ fi #SSE4.2 required by Clickhouse (https://clickhouse.yandex/docs/en/operations/requirements/) # On KVM, cpuinfo could falsely not report SSE 4.2 support, so skip the check. https://github.com/ClickHouse/ClickHouse/issues/20#issuecomment-226849297 IS_KVM=$(docker run --rm busybox grep -c 'Common KVM processor' /proc/cpuinfo || :) -if [[ "$IS_KVM" -eq 0 ]]; then +if [[ "$IS_KVM" -eq 0 && "$DOCKER_ARCH" = "x86_64" ]]; then SUPPORTS_SSE42=$(docker run --rm busybox grep -c sse4_2 /proc/cpuinfo || :) if [[ "$SUPPORTS_SSE42" -eq 0 ]]; then echo "FAIL: The CPU your machine is running on does not support the SSE 4.2 instruction set, which is required for one of the services Sentry uses (Clickhouse). See https://github.com/getsentry/self-hosted/issues/340 for more info." diff --git a/install/detect-platform.sh b/install/detect-platform.sh new file mode 100755 index 00000000000..23ddd4a1cec --- /dev/null +++ b/install/detect-platform.sh @@ -0,0 +1,30 @@ +echo "${_group}Detecting Docker platform" + + +# Sentry SaaS uses stock Yandex ClickHouse, but they don't provide images that +# support ARM, which is relevant especially for Apple M1 laptops, Sentry's +# standard developer environment. As a workaround, we use an altinity image +# targeting ARM. +# +# See https://github.com/getsentry/self-hosted/issues/1385#issuecomment-1101824274 +# +# Images built on ARM also need to be tagged to use linux/arm64 on Apple +# silicon Macs to work around an issue where they are built for +# linux/amd64 by default due to virtualization. +# See https://github.com/docker/cli/issues/3286 for the Docker bug. + +export DOCKER_ARCH=$(docker info --format '{{.Architecture}}') + +if [[ "$DOCKER_ARCH" = "x86_64" ]]; then + export DOCKER_PLATFORM="linux/amd64" + export CLICKHOUSE_IMAGE="yandex/clickhouse-server:20.3.9.70" +elif [[ "$DOCKER_ARCH" = "aarch64" ]]; then + export DOCKER_PLATFORM="linux/arm64" + export CLICKHOUSE_IMAGE="altinity/clickhouse-server:21.6.1.6734-testing-arm" +else + echo "FAIL: Unsupported docker architecture $DOCKER_ARCH." + exit 1 +fi +echo "Detected Docker platform is $DOCKER_PLATFORM" + +echo "${_endgroup}"