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: deployment docs (#751)

Myles Scolnickd527d69af37f
diff --git a/docs/guides/apps.md b/docs/guides/apps.md
index b744c328d7..1317b2e219 100644
--- a/docs/guides/apps.md
+++ b/docs/guides/apps.md
@@ -1,21 +1,24 @@
# Run as an app
The marimo CLI lets you run any notebook as an app: `marimo run` hides the
-notebook's code and starts a web server that hosts the resulting app.
+notebook's code and starts a web server that hosts the resulting app.
```
Usage: marimo run [OPTIONS] NAME
- Run as an app in read-only mode.
+ Run a notebook as an app in read-only mode.
- If NAME is a url, the app will be downloaded to a temporary file.
+ If NAME is a url, the notebook will be downloaded to a temporary file.
Example:
- * marimo run your_app.py
+ * marimo run notebook.py
Options:
-p, --port INTEGER Port to attach to.
+ --host TEXT Host to attach to.
--headless Don't launch a browser.
+ --include-code Include notebook code in the app.
+ --base-url TEXT Base URL for the server. Should start with a /.
--help Show this message and exit.
```
diff --git a/docs/guides/deploying/deploying_docker.md b/docs/guides/deploying/deploying_docker.md
new file mode 100644
index 0000000000..4a9bfb76d0
--- /dev/null
+++ b/docs/guides/deploying/deploying_docker.md
@@ -0,0 +1,86 @@
+# Deploying with Docker
+
+## Prerequisites
+
+- A marimo notebook or app: `app.py` that you want to deploy
+- A `requirements.txt` file that contains the dependencies needed for your application to run
+
+## Create a Dockerfile
+
+`Dockerfile` is a text file that contains instructions for building a Docker image. Here's an example `Dockerfile` for a marimo notebook:
+
+```Dockerfile
+# syntax=docker/dockerfile:1.4
+
+# Choose a python version that you know works with your application
+FROM python:3.9-slim
+
+WORKDIR /app
+
+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 . .
+
+
+
+EXPOSE 8080
+
+# Create a non-root user and switch to it
+RUN useradd -m app_user
+USER app_user
+
+CMD [ "marimo", "run", "app.py", "-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.
+
+A slimmer Dockerfile (by bytes) means quick to build, deploy, and start up.
+
+The `WORKDIR` sets the current working directory. In most cases, this does not need to be changed.
+
+The `COPY` steps will copy all the necessary files into your docker. By adding `--link`, we end up creating a new layer that does not get invalidated by previous changes. This can be especially important for expensive install steps that do not depend on each other.
+
+`RUN` lets us run shell commands. We can use this to install dependencies via apt-get, pip, or package managers. In our case, we use it to install our requirements.txt with pip.
+
+Our `EXPOSE` step tells us which port is exposed to be accessed from outside the Docker container. This will need to match the port at which we run our marimo application on.
+
+We then create a new user and switch to it with the `USER` instruction, in order to limit the permissions of the marimo application. This is not required, but recommended.
+
+The final step `CMD` instructions what command to run when we run our docker container. Here we run our marimo application at the port 8080.
+
+## Running your application 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
+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.
+
+## Health checks
+
+You can add a health check to your Dockerfile to ensure that your application is running as expected. This is especially useful when deploying to a cloud provider.
+
+```Dockerfile
+HEALTHCHECK --interval=30s --timeout=3s \
+ CMD curl -f http://localhost:8080/health || exit 1
+```
+
+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
+- `/api/status` - A status endpoint that returns a JSON object with the status of the server
diff --git a/docs/guides/deploying/deploying_marimo_cloud.md b/docs/guides/deploying/deploying_marimo_cloud.md
new file mode 100644
index 0000000000..d9ffe3d035
--- /dev/null
+++ b/docs/guides/deploying/deploying_marimo_cloud.md
@@ -0,0 +1,7 @@
+# Deploying to marimo cloud
+
+**marimo cloud** makes it easy to deploy and share your marimo notebooks and apps.
+
+If you would like to deploy your application to our [public gallery](https://marimo.io/@public), please reach out in our [Discord](https://discord.gg/JE7nhX6mD8).
+
+For privately hosted deployments, please join our waitlist for [marimo cloud](https://marimo.io/cloud).
diff --git a/docs/guides/deploying/index.md b/docs/guides/deploying/index.md
new file mode 100644
index 0000000000..a215777f76
--- /dev/null
+++ b/docs/guides/deploying/index.md
@@ -0,0 +1,41 @@
+# Deploying
+
+```{eval-rst}
+.. toctree::
+ :maxdepth: 2
+ :hidden:
+
+ deploying_docker
+ deploying_marimo_cloud
+```
+
+These guides help you deploy marimo notebooks and apps to your cloud or ours.
+
+| | |
+| :---------------------------- | :-------------------------------------------------- |
+| {doc}`deploying_docker` | Deploying marimo notebooks and apps with Docker |
+| {doc}`deploying_marimo_cloud` | Deploying marimo notebooks and apps to marimo cloud |
+
+## Health and status endpoints
+
+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
+- `/api/status` - A status endpoint that returns a JSON object with the status of the server
+
+## Configuration
+
+If you would like to deploy your application at a subpath, you can set the `--base-url` flag when running your application.
+
+```bash
+marimo run app.py --base-url /subpath
+```
+
+## Including code in your application
+
+You can include code in your application by using the `--include-code` flag when running your application.
+
+```bash
+marimo run app.py --include-code
+```
diff --git a/docs/guides/index.md b/docs/guides/index.md
index 94319830db..9b6ab5a9c2 100644
--- a/docs/guides/index.md
+++ b/docs/guides/index.md
@@ -16,23 +16,25 @@
apps
scripts
best_practices
+ deploying/index
```
These guides cover marimo's core concepts.
-| | |
-| :-------------------- | :---------------------------------------- |
-| {doc}`overview` | An overview of basic concepts |
-| {doc}`reactivity` | How reactive execution works |
-| {doc}`interactivity` | Using interactive UI elements |
-| {doc}`outputs` | Markdown, plots, and other visual outputs |
-| {doc}`editor_features`| View variables, cell dependencies, errors, and more |
-| {doc}`dataframes` | Working with dataframes |
-| {doc}`plotting` | Interactive and reactive plots |
-| {doc}`state` | Mutable, reactive state |
-| {doc}`apps` | Running notebooks as apps |
-| {doc}`scripts` | Running notebooks as scripts |
-| {doc}`best_practices` | Best practices when working with marimo |
+| | |
+| :--------------------- | :-------------------------------------------------- |
+| {doc}`overview` | An overview of basic concepts |
+| {doc}`reactivity` | How reactive execution works |
+| {doc}`interactivity` | Using interactive UI elements |
+| {doc}`outputs` | Markdown, plots, and other visual outputs |
+| {doc}`editor_features` | View variables, cell dependencies, errors, and more |
+| {doc}`dataframes` | Working with dataframes |
+| {doc}`plotting` | Interactive and reactive plots |
+| {doc}`state` | Mutable, reactive state |
+| {doc}`apps` | Running notebooks as apps |
+| {doc}`scripts` | Running notebooks as scripts |
+| {doc}`best_practices` | Best practices when working with marimo |
+| {doc}`deploying/index` | Deploying marimo notebooks and apps |
```{admonition} Learn by doing!
:class: tip
diff --git a/docs/index.md b/docs/index.md
index 2b6213ed32..fa3e6424d5 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -2,22 +2,24 @@
<img src="_static/marimo-logotype-thick.svg" width="210px">
</p>
-
**marimo** is a reactive notebook for Python. It allows you to rapidly experiment
with data and models, code with confidence in your notebook's correctness, and
productionize notebooks as pipelines or interactive web apps.
-
::::{tab-set}
:::{tab-item} install with pip
+
```bash
pip install marimo && marimo tutorial intro
```
+
:::
:::{tab-item} install with conda
+
```bash
conda install -c conda-forge marimo && marimo tutorial intro
```
+
:::
::::
@@ -27,7 +29,7 @@ conda install -c conda-forge marimo && marimo tutorial intro
- **interactive**: bind sliders, tables, plots, and more to Python — no callbacks required
- **reproducible**: no hidden state, deterministic execution order
- **deployable**: executable as a script, deployable as an app
-- **developer-friendly**: git-friendly `.py` file format, GitHub Copilot, fast autocomplete, code formatting, and more
+- **developer-friendly**: git-friendly `.py` file format, GitHub Copilot, fast autocomplete, code formatting, and more
_marimo was built from the ground up to solve many <a
href="/faq.html#faq-jupyter">well-known problems associated with traditional