Skip to content

Commit

Permalink
fix(docker): add macOS arm64 support for JDK-8345296 workaround
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Le <charlie_le@apple.com>
  • Loading branch information
CharlieTLe committed Jan 11, 2025
1 parent 6ffe00f commit afefb0a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions .env.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_JAVA_OPTIONS=-XX:UseSVE=0
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ MISSPELL = $(TOOLS_DIR)/$(MISSPELL_BINARY)

DOCKER_COMPOSE_CMD ?= docker compose
DOCKER_COMPOSE_ENV=--env-file .env --env-file .env.override
DOCKER_COMPOSE_BUILD_ARGS=

# Java Workaround for macOS 15.2+ and M4 chips (see https://bugs.openjdk.org/browse/JDK-8345296)
ifeq ($(shell uname -m),arm64)
ifeq ($(shell uname -s),Darwin)
DOCKER_COMPOSE_ENV+= --env-file .env.arm64
DOCKER_COMPOSE_BUILD_ARGS+= --build-arg=_JAVA_OPTIONS=-XX:UseSVE=0
endif
endif

# see https://github.com/open-telemetry/build-tools/releases for semconvgen updates
# Keep links in semantic_conventions/README.md and .vscode/settings.json in sync!
Expand Down Expand Up @@ -77,11 +86,11 @@ install-tools: $(MISSPELL)

.PHONY: build
build:
$(DOCKER_COMPOSE_CMD) build
$(DOCKER_COMPOSE_CMD) build $(DOCKER_COMPOSE_BUILD_ARGS)

.PHONY: build-and-push
build-and-push:
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build --push
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(DOCKER_COMPOSE_BUILD_ARGS) --push

# Create multiplatform builder for buildx
.PHONY: create-multiplatform-builder
Expand Down Expand Up @@ -209,7 +218,7 @@ ifdef SERVICE
endif

ifdef service
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(service)
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) build $(DOCKER_COMPOSE_BUILD_ARGS) $(service)
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) stop $(service)
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) rm --force $(service)
$(DOCKER_COMPOSE_CMD) $(DOCKER_COMPOSE_ENV) create $(service)
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ services:
- OTEL_LOGS_EXPORTER=otlp
- OTEL_SERVICE_NAME=ad
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS=-XX:UseSVE=0
- _JAVA_OPTIONS
depends_on:
otel-collector:
condition: service_started
Expand Down Expand Up @@ -657,7 +657,7 @@ services:
- DISABLE_INSTALL_DEMO_CONFIG=true
- DISABLE_SECURITY_PLUGIN=true
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS=-XX:UseSVE=0
- _JAVA_OPTIONS
ulimits:
memlock:
soft: -1
Expand Down
8 changes: 3 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ services:
- OTEL_LOGS_EXPORTER=otlp
- OTEL_SERVICE_NAME=ad
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS=-XX:UseSVE=0
- _JAVA_OPTIONS
depends_on:
otel-collector:
condition: service_started
Expand Down Expand Up @@ -247,8 +247,6 @@ services:
- OTEL_INSTRUMENTATION_MESSAGING_EXPERIMENTAL_RECEIVE_TELEMETRY_ENABLED=true
- OTEL_RESOURCE_ATTRIBUTES
- OTEL_SERVICE_NAME=fraud-detection
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS=-XX:UseSVE=0
depends_on:
otel-collector:
condition: service_started
Expand Down Expand Up @@ -663,7 +661,7 @@ services:
- OTEL_SERVICE_NAME=kafka
- KAFKA_HEAP_OPTS=-Xmx400m -Xms400m
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS=-XX:UseSVE=0
- _JAVA_OPTIONS
healthcheck:
test: nc -z kafka 9092
start_period: 10s
Expand Down Expand Up @@ -805,7 +803,7 @@ services:
- DISABLE_INSTALL_DEMO_CONFIG=true
- DISABLE_SECURITY_PLUGIN=true
# Workaround on OSX for https://bugs.openjdk.org/browse/JDK-8345296
- _JAVA_OPTIONS=-XX:UseSVE=0
- _JAVA_OPTIONS
ulimits:
memlock:
soft: -1
Expand Down
5 changes: 3 additions & 2 deletions src/ad/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


FROM --platform=${BUILDPLATFORM} eclipse-temurin:21-jdk AS builder
ENV _JAVA_OPTIONS=-XX:UseSVE=0
ARG _JAVA_OPTIONS
WORKDIR /usr/src/app/

COPY ./src/ad/gradlew* ./src/ad/settings.gradle* ./src/ad/build.gradle ./
Expand All @@ -23,11 +23,12 @@ RUN ./gradlew installDist -PprotoSourceDir=./proto
FROM eclipse-temurin:21-jre

ARG OTEL_JAVA_AGENT_VERSION
ARG _JAVA_OPTIONS

WORKDIR /usr/src/app/

COPY --from=builder /usr/src/app/ ./
ADD --chmod=644 https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$OTEL_JAVA_AGENT_VERSION/opentelemetry-javaagent.jar /usr/src/app/opentelemetry-javaagent.jar
ENV _JAVA_OPTIONS="-XX:UseSVE=0"
ENV JAVA_TOOL_OPTIONS=-javaagent:/usr/src/app/opentelemetry-javaagent.jar

EXPOSE ${AD_PORT}
Expand Down

0 comments on commit afefb0a

Please sign in to comment.