Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Add basic support for Apple Silicon #852

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ COMPOSE_FILE := docker-compose-host.yml
COMPOSE_FILE := $(COMPOSE_FILE):docker-compose-themes.yml
COMPOSE_FILE := $(COMPOSE_FILE):docker-compose-watchers.yml
COMPOSE_FILE := docker-compose.yml:$(COMPOSE_FILE)
ifdef COMPOSE_OVERRIDES_FILE
COMPOSE_FILE := $(COMPOSE_FILE):$(COMPOSE_OVERRIDES_FILE)
endif

# Check system architecture, e.g. use arm64v8 on Apple Silicon / M1
OS_ARCH := $(shell uname -p)
ifeq ($(OS_ARCH),arm)
COMPOSE_FILE := $(COMPOSE_FILE):docker-compose-arm64v8.yml
endif
Comment on lines +82 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this should be opt-in. I can't think of why someone with apple silicon would not want to do this, but putting this comment here in case someone reading this can think of a reason.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the result is pretty slow. But it works, and it's definitely better than not having a devstack at all on M1 Mac.

I am dissatisfied with the performance though, which is why I've now tried building a native ARM image for edxapp instead. If I could get that working, I'd definitely change the PR to use that approach instead. I hit a roadblock, which I think is due to the old version of ansible being used.


# Tell Docker Compose that the Compose file list uses a colon as the separator.
COMPOSE_PATH_SEPARATOR := :
Expand Down
86 changes: 86 additions & 0 deletions docker-compose-arm64v8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# These overrides allow Open edX devstack to run on ARM64 systems like the M1 Macs (Apple Silicon)
# However, these amd64 images are likely to be very slow. We should replace them with ARM64 versions
# as much as possible.
version: "2.1"

services:

chrome:
platform: linux/amd64

coursegraph:
platform: linux/amd64

devpi:
platform: linux/amd64

elasticsearch:
platform: linux/amd64

# elasticsearch7:
# image: elasticsearch:7.8.1 is available in linux/arm64/v8

# elasticsearch710:
# image: elasticsearch:7.10.1 is available in linux/arm64/v8

firefox:
platform: linux/amd64

# memcached:
# image: memcached:1.5.10-alpine is available in linux/arm64/v8

# mongo:
# image: mongo:4.2.14 is available in linux/arm64/v8

mysql57:
#image: mysql:5.7 doesn't support linux/arm64/v8
image: mariadb:10.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you are using platform: linux/amd64 in other places in this PR. Have you tried doing that with mysql57, if so, how did it go?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try it, so I'm not sure. Based on my experience with the other images, I suspect it would work fine, but all the database queries would be a bit slower, degrading overall performance.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what it's worth, the MySQL 8 images published by Oracle support arm64/v8: https://hub.docker.com/r/mysql/mysql-server/tags


redis:
# image: redis:2.8 is ancient and doesn't support linux/arm64/v8
image: redis:5
Comment on lines +39 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much were you able to test this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't yet done extensive tests. Only basic things like logging into the LMS, using the django admin, and running parts of the test suite. However, so far I haven't encountered any issues.


# ================================================
# edX services
# ================================================

credentials:
platform: linux/amd64

discovery:
platform: linux/amd64

ecommerce:
platform: linux/amd64

edx_notes_api:
platform: linux/amd64

forum:
platform: linux/amd64

lms:
platform: linux/amd64

insights:
platform: linux/amd64

analyticsapi:
platform: linux/amd64

registrar:
platform: linux/amd64

registrar-worker:
platform: linux/amd64

studio:
platform: linux/amd64

xqueue:
platform: linux/amd64

xqueue_consumer:
platform: linux/amd64

# edX Microfrontends all use node:12 which has linux/arm64/v8 builds.
Copy link

@msegado msegado Nov 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the MFEs have an issue too; optipng-bin fails to compile on M1 (see imagemin/optipng-bin#117), which then breaks the build since it's called later in the pipeline.

As suggested in the issue above, one can work around this for now by setting CPPFLAGS=-DPNG_ARM_NEON_OPT=0. I can confirm that this works if added as an environment variable to the MFE services.