Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

docs: deploying to hugging face (#2627)

Myles Scolnickb69715ceb5f2
diff --git a/docs/guides/deploying/deploying_docker.md b/docs/guides/deploying/deploying_docker.md
index 90f8ea769e..32af45e568 100644
--- a/docs/guides/deploying/deploying_docker.md
+++ b/docs/guides/deploying/deploying_docker.md
@@ -13,19 +13,24 @@
# syntax=docker/dockerfile:1.4
# Choose a python version that you know works with your application
-FROM python:3.9-slim
+FROM python:3.11-slim
+
+# Install uv for fast package management
+COPY --from=ghcr.io/astral-sh/uv:0.4.20 /uv /bin/uv
+ENV UV_SYSTEM_PYTHON=1
WORKDIR /app
+# Copy requirements file
COPY --link requirements.txt .
-# Install the requirements
-RUN pip install -r requirements.txt
-
-# You may copy more files like csv, images, data
-COPY --link app.py .
-# COPY . .
+# Install the requirements using uv
+RUN uv pip install -r requirements.txt
+# Copy application files
+COPY --link app.py .
+# Uncomment the following line if you need to copy additional files
+# COPY --link . .
EXPOSE 8080
@@ -38,7 +43,7 @@ CMD [ "marimo", "run", "app.py", "--host", "0.0.0.0", "-p", "8080" ]
## Breaking it down
-`FROM` instructs what base image to choose. In our case, we chose Python 3.9 with the “slim” variant. This removes a lot of extra dependencies. You can always add them back as needed.
+`FROM` instructs what base image to choose. In our case, we chose Python 3.11 with the “slim” variant. This removes a lot of extra dependencies. You can always add them back as needed.
A slimmer Dockerfile (by bytes) means quick to build, deploy, and start up.
@@ -56,19 +61,19 @@ The final step `CMD` instructions what command to run when we run our docker con
## Running your application locally
-Once you have your Dockerfile and your application files. You can test it out locally.
+Once you have your Dockerfile and your application files, you can test it out locally:
```bash
# Build your image, and tag it as my_app
docker build -t my_app .
-# Start your container, and map our port 8080 to our containers 8080
+# Start your container, mapping port 8080
docker run -p 8080:8080 -it my_app
# Visit http://localhost:8080
```
-After you have verified your application runs without errors. You can use these files to deploy your application on your favorite cloud provider that supports deploying dockererized applications.
+After verifying that your application runs without errors, you can use these files to deploy your application on your preferred cloud provider that supports dockerized applications.
## Health checks
@@ -81,6 +86,5 @@ HEALTHCHECK --interval=30s --timeout=3s \
The following endpoints may be useful when deploying your application:
-- `/health` - A health check endpoint that returns a 200 status code if the application is running as expected
-- `/healthz` - Same as above, just a different name for easier integration with cloud providers
+- `/health` or `/healthz` - A health check endpoint that returns a 200 status code if the application is running as expected
- `/api/status` - A status endpoint that returns a JSON object with the status of the server
diff --git a/docs/guides/deploying/deploying_hugging_face.md b/docs/guides/deploying/deploying_hugging_face.md
new file mode 100644
index 0000000000..cafe085273
--- /dev/null
+++ b/docs/guides/deploying/deploying_hugging_face.md
@@ -0,0 +1,15 @@
+# Deploy to Hugging Face
+
+Hugging Face is a platform that allows you to deploy machine learning models and applications easily.
+You can deploy a marimo notebook as an interactive web app on Hugging Face Spaces with just a few steps.
+
+## Deploy
+
+To deploy your marimo notebook to Hugging Face Spaces:
+
+1. Create a new Space on Hugging Face by forking or copying the following template: <https://huggingface.co/spaces/marimo-team/marimo-app-template/tree/main>
+2. Replace the contents of the `app.py` file with your marimo notebook.
+3. Update the `requirements.txt` file to include any other dependencies your notebook requires.
+4. Commit these files to your Space, and Hugging Face will automatically deploy your marimo notebook as an interactive web app.
+
+For more detailed instructions and advanced configurations, please refer to the [Hugging Face Spaces documentation](https://huggingface.co/docs/hub/spaces-overview).
diff --git a/docs/guides/deploying/index.md b/docs/guides/deploying/index.md
index adb38aaa06..9a1ee4e151 100644
--- a/docs/guides/deploying/index.md
+++ b/docs/guides/deploying/index.md
@@ -3,8 +3,7 @@
You can deploy marimo in three ways:
1. via an **edit server**, which allows you to create and edit notebooks. On
- the CLI, this is launched with `marimo edit`, and is similar to `jupyter
- notebook`.
+ the CLI, this is launched with `marimo edit`, and is similar to `jupyter notebook`.
2. via a **run server**, which allows you serve marimo notebooks as read-only
web apps. On the CLI, this is launched with `marimo run notebook.py`
3. programmatically, which allows you serve **read-only** marimo apps
@@ -44,6 +43,7 @@ These guides help you deploy marimo notebooks as read-only apps.
| {doc}`authentication` | Authentication and security |
| {doc}`deploying_public_gallery` | Deploy to our public gallery |
| {doc}`deploying_marimo_cloud` | Deploy to Marimo Cloud |
+| {doc}`deploying_hugging_face` | Deploy to Hugging Face |
| {doc}`deploying_ploomber` | Deploy to Ploomber Cloud |
### Health and status endpoints