Skip to content

Provide arm64 builds for shiny-server #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
andresrcs opened this issue Aug 22, 2022 · 9 comments
Open

Provide arm64 builds for shiny-server #532

andresrcs opened this issue Aug 22, 2022 · 9 comments

Comments

@andresrcs
Copy link

Can you consider providing arm64 builds for shiny-server the same way the RStudio IDE is providing experimental builds for arm64? If they already have the workflow in place I guess it would be simple to borrow from them?

@lvalnegri
Copy link

I wrote down some notes a while back, they can still be valid https://github.com/lvalnegri/workshops-setup_cloud_analytics_machine/blob/master/raspberry-pi_jetson-nano.md

@andresrcs
Copy link
Author

@lvalnegri Thanks but I know how to compile shiny-server for arm, I even have blog posts about it, the idea behind this request is to make the installation process easier and less time-consuming. I thought since other RStudio development team already has a workflow for compiling for arm, they could implement it as well.

@jcheng5
Copy link
Member

jcheng5 commented Aug 22, 2022

It's a good idea, thank you for the suggestion.

@mmuurr
Copy link

mmuurr commented Jan 10, 2024

I'm curious if there's been any further discussion about, or planning for, pre-built ARM64 Shiny Server binaries.
Apple silicon is popular (to say the least!) at this point and running via x86 emulation isn't the best.
Specifically, pre-built ARM64 binaries would unblock this.

@James-G-Hill
Copy link

@mmuurr can you please explain / point me in the direction of the emulation you mentioned?

@tw0flower
Copy link

@James-G-Hill AFAIK, only UTM allows to emulate x86_64 on macOS, though you're probably going to have very poor performance.

In my case, I'm running aarch64 Linux virtual machines on macOS to automate the deployment of Shiny Server in a production environment. The lack of packages makes it very difficult to mirror our x86_64 production environment.

A lot of cloud providers offer aarch64 VMs and it could be first step towards supporting them as well.

It's great to have aaarch64 builds for RStudio-Server - even if they're experimental - and I would love to see the same thing for Shiny-Server.

@mmuurr
Copy link

mmuurr commented Nov 10, 2024

@James-G-Hill sorry for the super-late reply. If you haven't already figured it out, one solution is to use containers. And with containers there are effectively two steps required (assuming you want to build upon an image ... if you just want to run Shiny Server you may be able to skip to the second step, depending your needs).

Step 1: Cross-platform builds

Use the docker buildx build command with the --platform switch to build for an architecture that's (possibly) different than your builder host (e.g. your ARM64 Mac). So, for example, a possible build command might look like so:

docker buildx build --platform linux/amd64 -f Dockerfile .

The image produced will then run on a linux/amd64-based host, but will not run (without emulation) on, e.g., your ARM64 Mac. If your Dockerfile's base image is only available with linux/amd64, this is probably the best way to move forward (at the expense of emulation, described below). This is how I've dealt with Rocker's rocker/shiny-verse not supporting arm64 archs.

You can also create images that are multi-arch, e.g. with docker buildx build --platform linux/arm64,linux/amd64 .... Then, when you want to run that image as a container, the container runtime will typically select whichever arch matches your host's native arch. (You can override this again with something like docker run --platform linux/amd64 to run a specific arch on-demand.)

Step 2: Runtime emulation

I don't know how this is managed on other hosts and other container runtimes (e.g. containerd or podman), but they'll all be similar to how it's done with Docker and the Apple-silicon ARM64 machines: emulation. If you go into Docker settings, you'll need to enable Rosetta emulation. Via the UI it'll look like so:
image
With that enabled, you'll be able to run containers targeting the amd64 (or x86_64, which is an alias) platforms. Just a standard docker run ... command should work (you won't need to specify the arch, unless, as mentioned above, you really want to run a specific arch, e.g. to test emulation, which I assume is not what you're seeking to do here :-)).


All of this feels pretty clunky, though, and I still have some hope 🤞 that there'll eventually (pretty please, with sugar on top?) be official ARM64 Shiny Server binaries, since the Apple's M-series silicon is now well-established (and very performant) and AWS's Graviton silicon is increasingly forming the backbone of AWS's own internal infrastructure. In short, ARM64 isn't niche.

@philibe
Copy link

philibe commented Jan 2, 2025

Post with similar direction with the @mmuurr post but on Orbstack and with standard amd64 binaries deb package from https://download3.rstudio.org/ubuntu-18.04/x86_64/shiny-server-1.5.22.1017-amd64.deb

I've tried shiny-server on Apple M3 Pro MacOs 15.2 Orbstack 1.9.2.

In Orbstack Linux Machine Ubuntu:

# Enable multi-arch
sudo dpkg --add-architecture amd64
# Fix repos
echo 'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports oracular main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports oracular-updates main restricted universe multiverse
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports oracular-security main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu oracular main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu oracular-updates main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu oracular-security main restricted universe multiverse' | sudo tee /etc/apt/sources.list.d/oracular.list

# Install libraries
sudo apt update
sudo apt install libc6:amd64

But I get error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

  • Maybe not mandatory (In Orbstack Linux Machine Ubuntu)
sudo apt-get install lib32stdc++6
sudo apt-get install g++-multilib 

And shiny-server.service starts without crashes :)
(In Orbstack Linux Machine Ubuntu)

sudo systemctl status shiny-server.service
● shiny-server.service - ShinyServer
     Loaded: loaded (/etc/systemd/system/shiny-server.service; enabled; preset: enabled)
     Active: active (running) since Thu 2025-01-02 22:41:39 CET; 29min ago
 Invocation: a50e81aef06f4f1381c31ea7aff2942d
   Main PID: 8052 (shiny-server)
      Tasks: 11 (limit: 10787)
     Memory: 87.4M (peak: 111.9M)
        CPU: 1.739s
     CGroup: /system.slice/shiny-server.service
             └─8052 "[rosetta]" /opt/shiny-server/ext/node/bin/shiny-server /opt/shiny-server/ext/node/bin/shiny-server /opt/shiny-server/lib/main.js

It works from a MacOs browser via Orbstack Linux Machine Ubuntu without port forwarding, because "Allow access to container domain & IPs" is checked (by default) in Orbstack / Settings / Network

(I don't know if it works on native Ubuntu arm64.)

Note also, not tried yet, the NEWS of release v1.5.23.1030 Sep 30, 2024

Now works with macOS and with Linux ARM64, when built from source.

from https://github.com/rstudio/shiny-server/blob/v1.5.23.1030/NEWS

@philibe
Copy link

philibe commented Jan 31, 2025

Ubuntu amd64 on arm 64 is emulated since Jan 14th 2025 on the Docker of Orbstack 1.9.4:

Install Rosetta on MacOs.

Dockerfile:

FROM --platform=${BUILDPLATFORM}  ubuntu:oracular AS base
WORKDIR /
RUN apt update -y && apt-get install -y r-base r-cran-shiny gdebi-core wget 
RUN wget https://download3.rstudio.org/ubuntu-18.04/x86_64/shiny-server-1.5.22.1017-amd64.deb
RUN gdebi -n shiny-server-1.5.22.1017-amd64.deb
RUN chown -R shiny.shiny /var/lib/shiny-server
EXPOSE 3838
ENTRYPOINT ["/opt/shiny-server/bin/shiny-server"]

Docker Build:

  • docker build --build-arg BUILDPLATFORM=linux/amd64 -t shiny-server:latest -f Dockerfile .

Docker Run. (with 3839 on my example):

  • docker run -p 3839:3838 --platform linux/amd64 --user shiny shiny-server

And here we are on a browser (with 3839):

Édit:

install.packages("shiny") works also inside this x86 docker in the same arm64 MacBook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants