Overview

Spongecake includes a lightweight web server in the Spongecake container that allows you to execute desktop actions through a REST API.

When you define a host in the Desktop constructor, Spongecake will send all actions to a lightweight web server in the container that allows you to execute desktop actions through the REST API.

This enables self-hosting spongecake in a cloud environment where you can hit the API endpoint with commands.

Prerequisites

Before you can use the remote API, you need to have a remote server running with the Spongecake container. You can use a cloud provider like AWS, GCP, or Azure to host the container and run the spongecake default container found here in docker hub.

Using a Remote Host

Once you have a remote host to use, specify the host and api_port (default 8000) when initializing the desktop class.

Note: You don’t need to run the start() command here, as the server should already be started.

Now you can use the action() command just like you would locally! The desktop container will allow you to connect through VNC using the same host (default port 5900).

All other desktop actions (click, type_text, etc.) will also work normally once the host parameter is set

⚠️ SECURITY WARNING: The container’s web server has no authentication or encryption by default. Anyone with network access to the API port can control the container. For security-sensitive applications or when running in production environments, you should:

  • Implement proper authentication if API access is required
  • Consider network isolation or firewall rules to restrict access

Using custom docker images

You can use custom docker images when running desktops in the cloud, just like you can locally.

You will need to ensure that the custom docker image has a server running on the API port (default 8000) to handle the API requests, and execute the required actions.

spongecake/docker/api_server.py

This server implementation is how the current spongecake container runs the required commands. This particular implementation will only work in a linux environment.