Would it be possible to add something like ssh console

Hello Anvil team!

Would it be possible to add something like ssh for managing an application code and run some tools on it?
For example, maybe it would be handy to download C++ code and run in-place compilation for Python extensions with tools like Cython

Thank you.

Hi @andreikeino,

The specific thing you’re asking for would be very difficult to provide, but the good news is that you can already accomplish what you want! If you want to execute some commands to install C++ or Cython extensions, you can do that using pre-install and post-install scripts.

If you’re interested in the background, here’s why that is:

The server side of your Anvil app is not actually a virtual machine with a persistent disk, where you could SSH in and start mucking around with files with those changes persisted forever. If we’d built Anvil like that, your apps would be very fragile – you would end up with a “snowflake” setup that could only be recreated with a long series of manual actions, most of which you’d forgotten over the months and years, and so if it broke it would be very hard to get it working again.

Instead, modern best practice is to store a recipe - a set of instructions for rebuilding your environment at will. That way, if you have to rebuild your environment from scratch, you just follow the recipe. This also means that we can freely spin up and tear down environments on demand. (The slogan for this is treating servers, or environments, as “cattle, not pets”.)

The recipe for your Anvil app’s server environment is (a) a “base image” (eg “Python 3.10 minimal”); (b) a requirements.txt specifying all the packages you want installed; and (c) pre- and post-install scripts to run - you guessed it - before and after installing those packages.

This installation is then run to create an image, which we store. When your app runs server code, we launch your server code in that image, with all those packages (and the effect of your scripts) ready to use. When your app hasn’t been active for a while (quite soon if you’re on a Free plan, more reluctantly on a Business plan), we shut down that server environment. And if your app hasn’t been used for a long time, we’ll garbage-collect the image rather than storing gigabytes of data on our servers forever. If your app is needed again, we can rebuild your image from scratch using the recipe – the app will take a “slow start” penalty, but it will come roaring back even after years in hibernation, without committing us to store many gigs of data for every Free user who’s ever built a project.

And that’s why we can’t give you SSH access to your server environment - there is no one persistent filesystem to modify! Use pre- and post-install scripts instead for any setup your app’s environment needs.

4 Likes