Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Codespaces: how to set x86_64, AMD64, ARM64 platform?

First, the question: is there a way to choose the platform (e.g. x86_64, AMD64, ARM64) for a GitHub Codespace?

Here's what I've found so far:

Attempt 1 (not working):

From within GitHub.com, you can choose the "machine" for a Codespace, but the only options are RAM and disk size.

Attempt 2 (EDIT: not working): devcontainer.json

When you create a Codespace, you can specify options by creating a top-level .devcontainer folder with two files: devcontainer.json and Dockerfile

Here you can customize runtimes, installed packages, etc., but the docs don't say anything about determining architecture...

...however, the VSCode docs for devcontainer.json has a runArgs option, which "accepts Docker CLI arguments"...

and the Docker CLI docs on --platform say you should be able to pass --platform linux/amd64 or --platform linux/arm64, but...

When I tried this, the Codespace would just hang, never finishing building.

Attempt 3 (in progress): specify in Dockerfile

This route seems the most promising, but it's all new to me (containerization, codespaces, docker). It's possible that Attempts 2 and 3 work in conjunction with one another. At this point, though, there are too many new moving pieces, and I need outside help.

  1. Does GitHub Codespaces support this?
  2. Would you pass it in the Dockerfile or devcontainer.json? How?
  3. How would you verify this, anyway? [Solved: dpkg --print-architecture or uname -a]
  4. For Windows, presumably you'd need a license (I didn't see anything on GitHub about pre-licensed codespaces) -- but that might be out of scope for the question.

References:
https://code.visualstudio.com/docs/remote/devcontainerjson-reference
https://docs.docker.com/engine/reference/commandline/run/
https://docs.docker.com/engine/reference/builder/
https://docs.docker.com/desktop/multi-arch/
https://docs.docker.com/buildx/working-with-buildx/

like image 334
ultraGentle Avatar asked Dec 03 '21 19:12

ultraGentle


2 Answers

EDIT: December 2021

I received a response from GitHub support:

The VM hosts for Codespaces are only x86_64 and we do not offer any ARM64 machines.

So for now, setting the platform does nothing, or fails.

But if they end up supporting multiple platforms, you should be able to (in Dockerfile)

RUN --platform=arm64|amd64|x86-64 [image-name],

Which is working for me in the non-cloud version of Docker.


Original answer:

I may have answered my own question

In Dockerfile:

I had RUN alpine

changed to

RUN --platform=linux/amd64 alpine

or

RUN --platform=linux/x86-64 alpine

checked at the command line with

uname -a to print the architecture.

Still verifying, but seems promising. [EDIT: Nope]

So, despite the above, I can only get GitHub codespaces to run x86-64. Nevertheless, the above syntax seems correct.

A clue:

In the logs that appear while the codespace is building, I saw target OS: x86

Maybe GitHub just doesn't support other architectures yet. Still investigating.

like image 115
ultraGentle Avatar answered Oct 07 '22 19:10

ultraGentle


Currently only x64 based hosts running Linux are supported for Codespaces. Other hardware and host is types are yet to be announced.

like image 30
jessehouwing Avatar answered Oct 07 '22 17:10

jessehouwing