Hubs-Foundation / hubs-compose

Local development setup for Hubs
Mozilla Public License 2.0
41 stars 32 forks source link

ARM64 support #45

Open Utopiah opened 4 months ago

Utopiah commented 4 months ago

Getting exec format error on

while

do run fine.

Utopiah commented 4 months ago

BTW this is on a RPi with Debian 12.4

I have the same problem trying to run HubsCE with kubernetes and kind or k3s so I imagine it's the way some of those images are built that aren't properly cross-platform.

Utopiah commented 4 months ago

The docker-compose and dockerfiles seems to explicitly target amd64.

Utopiah commented 4 months ago

FWIW bin/init failed due to

npm ERR! npm ERR! command sh -c node install.js
npm ERR! npm ERR! PhantomJS not found on PATH
npm ERR! npm ERR! Unexpected platform or architecture: linux/arm64

I believe for hubs-compose-hubs-client.

Briefly trying bin/up anyway despite this error shows other errors so maybe the ARM64 build process should be investigated if Raspberry Pis are consider popular targets.

Utopiah commented 4 months ago

FWIW on AMD64 on my desktop had no problem, whole setup took 10min and worked right away.

I did so as I'm not familiar with mutagen and wanted to insure I did the setup right.

So yes I believe some of the images should be buildable on ARM64.

Utopiah commented 4 months ago

Note that this https://github.com/mozilla/reticulum/issues/711 might be problematic.

Utopiah commented 3 months ago

Note that bin/init then bin/up (surprisingly enough) worked well (after few retries but not modifying files iirc) on an M1 Max which is also arm64.

Utopiah commented 3 months ago

So in hubs-client getting

npm ERR! code 1
npm ERR! git dep preparation failed
npm ERR! command /usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/root/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm ERR! npm WARN deprecated gulp-header@1.8.12: Removed event-stream from gulp-header
npm ERR! npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
npm ERR! npm WARN deprecated jscs-preset-wikimedia@1.0.1: No longer maintained. We recomment migrating to ESLint with eslint-config-wikimedia.
npm ERR! npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm ERR! npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
npm ERR! npm WARN deprecated uuid@2.0.3: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm ERR! npm WARN deprecated json3@3.3.2: Please use the native JSON object instead of JSON 3
npm ERR! npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! npm WARN deprecated phantomjs-prebuilt@2.1.16: this package is now deprecated
npm ERR! npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm ERR! npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm ERR! npm WARN deprecated jscs@3.0.7: JSCS has merged with ESLint! See - https://medium.com/@markelog/jscs-end-of-the-line-bc9bf0b3fdb2
npm ERR! npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! npm notice 
npm ERR! npm notice New major version of npm available! 8.11.0 -> 10.5.0
npm ERR! npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.0>
npm ERR! npm notice Run `npm install -g npm@10.5.0` to update!
npm ERR! npm notice 
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /root/.npm/_cacache/tmp/git-cloneebXk1R/node_modules/phantomjs-prebuilt
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c node install.js
npm ERR! npm ERR! PhantomJS not found on PATH
npm ERR! npm ERR! Unexpected platform or architecture: linux/arm64
npm ERR! npm ERR! It seems there is no binary available for your platform/architecture
npm ERR! npm ERR! Try to install PhantomJS globally
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /root/.npm/_logs/2024-03-10T13_28_04_325Z-debug-0.log

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-03-10T13_27_32_406Z-debug-0.log

so wondering due to

npm ERR! npm ERR! Unexpected platform or architecture: linux/arm64
npm ERR! npm ERR! It seems there is no binary available for your platform/architecture
npm ERR! npm ERR! Try to install PhantomJS globally

so maybe modifying the Dockerfile to install according to https://github.com/fg2it/phantomjs-on-raspberry could help.

For example hubs-compose/dockerfiles/hubs.Dockerfile modified to

# syntax=docker/dockerfile:1
ARG NODE_VERSION=16.16

FROM --platform=linux/arm64 node:${NODE_VERSION}
RUN wget https://github.com/fg2it/phantomjs-on-raspberry/releases/download/v2.1.1-jessie-stretch-arm64/phantomjs -O /usr/local/bin/phantomjs
RUN chmod +x /usr/local/bin/phantomjs
COPY files/conditional-npm-ci /usr/local/bin/conditional-npm-ci

seems to work.

Utopiah commented 3 months ago

Now for Spoke getting

[9/10] ⠄ puppeteer
error /code/node_modules/puppeteer: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /code/node_modules/puppeteer
Output:
The chromium binary is not available for arm64: 
If you are on Ubuntu, you can install with: 

 apt-get install chromium-browser

which seems to be addressed at https://github.com/puppeteer/puppeteer/issues/7740 which leads to a built image via hubs-compose/dockerfiles/spoke.Dockerfile using e.g

# syntax=docker/dockerfile:1
ARG NODE_VERSION=16.13

FROM --platform=linux/arm64 node:${NODE_VERSION}

RUN apt-get update && apt-get install wget unzip -y

WORKDIR /
RUN wget https://playwright.azureedge.net/builds/chromium/1088/chromium-linux-arm64.zip
RUN unzip chromium-linux-arm64.zip && rm -f ./chromium-linux-arm64.zip

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV CHROME_PATH=/chrome-linux/chrome
ENV PUPPETEER_EXECUTABLE_PATH=/chrome-linux/chrome

HEALTHCHECK CMD curl -fk https://localhost:9090 || exit 1
WORKDIR /code
CMD ["./scripts/run-local-reticulum.sh"]

Note that this hasn't been tested in Spoke itself and might have version problems as mentioned in the issue. Unfortunately even though it does seem to build the image, it does not seem to work once launching via mutagen.

Seems that according to

error /code/node_modules/puppeteer: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /code/node_modules/puppeteer

the puppeteer module of node doesn't seems to find chromium.