Skip to content

Commit ddbf7cd

Browse files
Add ARM support (#1538)
Co-authored-by: Ethan Smith <[email protected]>
1 parent 3cbe130 commit ddbf7cd

File tree

6 files changed

+54
-3
lines changed

6 files changed

+54
-3
lines changed

clickhouse/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE}

clickhouse/config.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<yandex>
2-
<max_server_memory_usage_to_ram_ratio from_env="MAX_MEMORY_USAGE_RATIO" />
2+
<max_server_memory_usage_to_ram_ratio>
3+
<!-- This include is important!
4+
It is required for the version of Clickhouse
5+
used on ARM to read the environment variable. -->
6+
<include from_env="MAX_MEMORY_USAGE_RATIO"/>
7+
</max_server_memory_usage_to_ram_ratio>
38
<logger>
49
<level>information</level>
510
<console>1</console>

docker-compose.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ x-healthcheck-defaults: &healthcheck_defaults
1717
x-sentry-defaults: &sentry_defaults
1818
<<: *restart_policy
1919
image: sentry-self-hosted-local
20+
# Set the platform to build for linux/arm64 when needed on Apple silicon Macs.
21+
platform: ${DOCKER_PLATFORM:-}
2022
build:
2123
context: ./sentry
2224
args:
@@ -190,7 +192,12 @@ services:
190192
test: ["CMD-SHELL", "nc -z localhost 9092"]
191193
clickhouse:
192194
<<: *restart_policy
193-
image: "yandex/clickhouse-server:20.3.9.70"
195+
image: clickhouse-self-hosted-local
196+
build:
197+
context:
198+
./clickhouse
199+
args:
200+
BASE_IMAGE: "${CLICKHOUSE_IMAGE:-}"
194201
ulimits:
195202
nofile:
196203
soft: 262144

install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ source "$(dirname $0)/install/_lib.sh" # does a `cd .../install/`, among other
1111

1212
# Pre-flight. No impact yet.
1313
source parse-cli.sh
14+
source detect-platform.sh
1415
source dc-detect-version.sh
1516
source error-handling.sh
1617
source check-latest-commit.sh

install/check-minimum-requirements.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ source "$(dirname $0)/_min-requirements.sh"
66
function ver () { echo "$@" | awk -F. '{ printf("%d%03d%03d", $1,$2,$3); }'; }
77

88
DOCKER_VERSION=$(docker version --format '{{.Server.Version}}')
9+
10+
if [[ -z "$DOCKER_VERSION" ]]; then
11+
echo "FAIL: Unable to get docker version, is the docker daemon running?"
12+
exit 1
13+
fi
14+
915
if [[ "$(ver $DOCKER_VERSION)" -lt "$(ver $MIN_DOCKER_VERSION)" ]]; then
1016
echo "FAIL: Expected minimum docker version to be $MIN_DOCKER_VERSION but found $DOCKER_VERSION"
1117
exit 1
@@ -38,7 +44,7 @@ fi
3844
#SSE4.2 required by Clickhouse (https://clickhouse.yandex/docs/en/operations/requirements/)
3945
# On KVM, cpuinfo could falsely not report SSE 4.2 support, so skip the check. https://github.com/ClickHouse/ClickHouse/issues/20#issuecomment-226849297
4046
IS_KVM=$(docker run --rm busybox grep -c 'Common KVM processor' /proc/cpuinfo || :)
41-
if [[ "$IS_KVM" -eq 0 ]]; then
47+
if [[ "$IS_KVM" -eq 0 && "$DOCKER_ARCH" = "x86_64" ]]; then
4248
SUPPORTS_SSE42=$(docker run --rm busybox grep -c sse4_2 /proc/cpuinfo || :)
4349
if [[ "$SUPPORTS_SSE42" -eq 0 ]]; then
4450
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."

install/detect-platform.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
echo "${_group}Detecting Docker platform"
2+
3+
4+
# Sentry SaaS uses stock Yandex ClickHouse, but they don't provide images that
5+
# support ARM, which is relevant especially for Apple M1 laptops, Sentry's
6+
# standard developer environment. As a workaround, we use an altinity image
7+
# targeting ARM.
8+
#
9+
# See https://github.com/getsentry/self-hosted/issues/1385#issuecomment-1101824274
10+
#
11+
# Images built on ARM also need to be tagged to use linux/arm64 on Apple
12+
# silicon Macs to work around an issue where they are built for
13+
# linux/amd64 by default due to virtualization.
14+
# See https://github.com/docker/cli/issues/3286 for the Docker bug.
15+
16+
export DOCKER_ARCH=$(docker info --format '{{.Architecture}}')
17+
18+
if [[ "$DOCKER_ARCH" = "x86_64" ]]; then
19+
export DOCKER_PLATFORM="linux/amd64"
20+
export CLICKHOUSE_IMAGE="yandex/clickhouse-server:20.3.9.70"
21+
elif [[ "$DOCKER_ARCH" = "aarch64" ]]; then
22+
export DOCKER_PLATFORM="linux/arm64"
23+
export CLICKHOUSE_IMAGE="altinity/clickhouse-server:21.6.1.6734-testing-arm"
24+
else
25+
echo "FAIL: Unsupported docker architecture $DOCKER_ARCH."
26+
exit 1
27+
fi
28+
echo "Detected Docker platform is $DOCKER_PLATFORM"
29+
30+
echo "${_endgroup}"

0 commit comments

Comments
 (0)