From b96b4685204e4ba2429a6c56112697711d0fc00e Mon Sep 17 00:00:00 2001 From: Jonathan Payne Date: Mon, 25 May 2026 12:39:34 +0200 Subject: [PATCH] OpenConceptLab/ocl_issues#2538 | Add docker-compose.local.yml for native arm64 dev builds The published openconceptlab/oclapi2 images are amd64-only. On Apple Silicon and other arm64 hosts they run under Rosetta/QEMU emulation, and Celery's post-restart indexing saturates emulated cores hard enough to block the API for tens of seconds. Adds an opt-in compose override (mirroring the existing docker-compose.sso.yml pattern) that attaches build: . to the api service so the image gets compiled from the local Dockerfile against the host architecture. The other 8 services that share the same image tag pick up the locally-built image automatically. Measured on M4 MacBook + OrbStack: GET /orgs/ 10s timeout to ~20ms, POST /concepts/ 60s timeout to ~280ms. Production / CI behavior unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) --- README.md | 8 ++++++++ docker-compose.local.yml | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 docker-compose.local.yml diff --git a/README.md b/README.md index 19482f6a..a06c6a5a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,14 @@ The new and improved OCL terminology service v2 3. Go to http://localhost:8000/swagger/ to benefit. 4. Go to http://localhost:8080 for keyCloak. +### Dev Setup on Apple Silicon / arm64 +The published `openconceptlab/oclapi2` Docker images are amd64-only. On arm64 hosts (Apple M-series Macs, arm64 Linux) they run under Rosetta/QEMU emulation, and under load — especially Celery's post-restart indexing — the emulated cores saturate hard enough to block the API for tens of seconds. Use the local-build override to compile from the local Dockerfile instead: +1. `sysctl -w vm.max_map_count=262144` #required by Elasticsearch (no-op on Docker Desktop / OrbStack) +2. `docker compose -f docker-compose.yml -f docker-compose.local.yml up -d` +3. Go to http://localhost:8000/swagger/ to benefit. + +If you previously pulled the amd64 image and have it cached, force a one-time rebuild before step 2: `docker compose -f docker-compose.yml -f docker-compose.local.yml build api`. + ### Configuration #### Authentication OCL API supports authentication using 2 methods. One is Django Auth (integrated into API) and the other is SSO using external service supporting OpenID such as Keycloak, Active Directory, etc. diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 00000000..d9ab4c41 --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,23 @@ +# Opt-in override for local native builds on arm64 hosts (Apple Silicon Macs, +# arm64 Linux). The published openconceptlab/oclapi2 images are amd64-only; +# on arm64 they run under Rosetta/QEMU emulation, and once Celery indexing +# kicks in the emulated cores saturate hard enough to block the API for +# tens of seconds at a time. Building from the local Dockerfile (which uses +# python:3.12-slim, a multi-arch base) gives a native image and ~200x faster +# requests in practice. +# +# Usage: +# docker compose -f docker-compose.yml -f docker-compose.local.yml up -d +# +# If you previously pulled the amd64 image, force a one-time rebuild: +# docker compose -f docker-compose.yml -f docker-compose.local.yml build api +# +# The api service is the only one that needs `build:` — all other services +# that share the openconceptlab/oclapi2 image tag will reuse the locally- +# built image once it exists. + +services: + api: + build: + context: . + dockerfile: Dockerfile