volta-cli / volta

Volta: JS Toolchains as Code. ⚡
https://volta.sh
Other
10.31k stars 219 forks source link

Volta running on a Linux Docker container aarch64 on Mac M1 and AWS Graviton hosts #1282

Open fhperuchi opened 1 year ago

fhperuchi commented 1 year ago

Hello volta developers.

Do you know if it is possible to run volta inside a Docker container on a Mac M1 or AWS Graviton machines?

Docker container:

ubuntu@8a9bdf478dc6:~$ uname -a
Linux 8a9bdf478dc6 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
ubuntu@8a9bdf478dc6:~$ uname -m
aarch64
ubuntu@8a9bdf478dc6:~$ curl https://get.volta.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12319  100 12319    0     0  18142      0 --:--:-- --:--:-- --:--:-- 18142
Error: Sorry! Volta currently only provides pre-built binaries for x86_64 architectures.

I got this error running the volta shell installer there. Could you help me? Is there a way to build it from source and have the aarch64 binaries available on these type of environments (Docker container running on Mac M1 and AWS Graviton hosts)?

charlespierce commented 1 year ago

Hi @fhperuchi, thanks for the question! I'm far from an expert in Docker, but I believe the underlying issue is the same as #1049: We don't currently have pre-built binaries for ARM Linux (and I'm guessing that Docker on M1 uses ARM Linux by default since that's the architecture).

You should still be able to build from source—see the docs under "Development" here: https://docs.volta.sh/contributing/ You can use the volta-install.sh --release script to build and install locally, if that makes sense. Happy to help with that step if you run into any issues.

mosamlife commented 1 year ago

Hello @fhperuchi you can use this repo to download arm64 prebuilt binaries.

https://github.com/MyneTop/volta

knownasilya commented 1 year ago

This would be nice to have. I can't run my image locally 😢

NullVoxPopuli commented 1 year ago

Just ran in to this -- would love to use volta on linux + Arm

monovertex commented 1 year ago

Hi @fhperuchi, thanks for the question! I'm far from an expert in Docker, but I believe the underlying issue is the same as #1049: We don't currently have pre-built binaries for ARM Linux (and I'm guessing that Docker on M1 uses ARM Linux by default since that's the architecture).

You should still be able to build from source—see the docs under "Development" here: https://docs.volta.sh/contributing/ You can use the volta-install.sh --release script to build and install locally, if that makes sense. Happy to help with that step if you run into any issues.

I'm trying to do exactly this, but with the current script I get this error:

7 28.91 Installing Volta locally after compiling with '--release'

7 28.91 Checking for existing Volta installation

7 28.93 Error: Releases for non x64 architectures are not currently supported.

7 28.93 Error: Releases for 'Linux' are not yet supported.

I'm not sure if I'm doing something wrong or if I misunderstood what you meant.

kunev commented 1 year ago

Hi @fhperuchi, thanks for the question! I'm far from an expert in Docker, but I believe the underlying issue is the same as #1049: We don't currently have pre-built binaries for ARM Linux (and I'm guessing that Docker on M1 uses ARM Linux by default since that's the architecture). You should still be able to build from source—see the docs under "Development" here: https://docs.volta.sh/contributing/ You can use the volta-install.sh --release script to build and install locally, if that makes sense. Happy to help with that step if you run into any issues.

I'm trying to do exactly this, but with the current script I get this error:

7 28.91 Installing Volta locally after compiling with '--release'

7 28.91 Checking for existing Volta installation

7 28.93 Error: Releases for non x64 architectures are not currently supported.

7 28.93 Error: Releases for 'Linux' are not yet supported.

I'm not sure if I'm doing something wrong or if I misunderstood what you meant.

I have no idea why or what the actual problem is. I was trying to debug it by adding random print statements across the install scripts. I ended up adding echo "VOLTA_OS: $VOLTA_OS" > $(tty) after line 62 in ./dev/unix/release.sh. I can not imagine how this solves it, but it does. Apparently it still doesn't detect the OS version correctly as that variable is empty, but it did install properly in ~/.volta.

metalim commented 1 year ago

bump! Any reason why aarch64 is not yet supported on Linux, but is supported on Mac?

Adding 'linux-aarch64' to volta-install.sh seems to work

michaelr0 commented 3 weeks ago

bump! Any reason why aarch64 is not yet supported on Linux, but is supported on Mac?

Adding 'linux-aarch64' to volta-install.sh seems to work

For anyone coming to this thread as of 8 Jun 2024, volta-install.sh can be used to install Volta on aarch64 (if you pull from main or use a tag higher than 1.1.1)

However installing with

curl https://get.volta.sh | bash

Still does not work on a linux/aarch64 system or container as of version 1.1.1

But you can use docker in a few different ways,

You could specify linux/amd64 as the platform and then use the pre-compiled binary.

FROM --platform=linux/amd64 ubuntu:24.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install curl -y && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*

ENV VOLTA_HOME="/opt/volta"
ENV PATH="$VOLTA_HOME/bin:$PATH"

RUN curl https://get.volta.sh | bash

RUN volta install node

This may incur a slight performance decrease, but shouldn't be too noticable.

Or you could even compile the source and use it in another image.

FROM rust AS volta-binaries

WORKDIR /volta

RUN git clone --depth=1 https://github.com/volta-cli/volta .

RUN cargo build --release

## Build image
FROM ubuntu:24.04 AS volta-docker

ARG DEBIAN_FRONTEND=noninteractive

COPY --from=volta-binaries /volta/target/release/volta* /usr/local/bin/

RUN apt-get update && apt-get install curl -y && apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*

ENV VOLTA_HOME="/opt/volta"
ENV PATH="$VOLTA_HOME/bin:$PATH"

RUN volta setup
RUN volta install node

Seeing as I couldn't see a container available on Docker Hub, I have built some images for this (ubuntu or alpine, both in amd64 and aarch64 variants)

see https://github.com/michaelr0/volta-docker for details, feel free to use this either directly or as inspiration for your own Dockerfile.