Deploying on Docker

In this article we will deploy a simple Lona script using Docker and optionally Docker Compose.

See the lona-project-template for an example on how to run a Lona Project in Docker.

This article assumes that all files (, Dockerfile and optionally docker-compose.yml) are in the same directory, and all commands are run in this directory.


from lona_picocss import install_picocss

from lona.html import HTML, H1
from lona import View, App

app = App(__file__)

install_picocss(app)  # optional

app.settings.MAX_RUNTIME_THREADS = 50
app.settings.MAX_WORKER_THREADS = 100
app.settings.MAX_STATIC_THREADS = 20

class Index(View):
    def handle_request(self, request):
        return HTML(
            H1('Hello World'),
        )'', port=8080)
# Dockerfile

FROM python:3.11

RUN pip install lona lona-picocss  # lona-picocss is optional


CMD ["python", ""]

Run these two commands:

docker build -t lona-hello-world .
docker run -it -p 8080:8080 lona-hello-world

Docker Compose

To use Docker Compose, add this this config to the same directory.

# docker-compose.yml

version: "3"

            context: ./
            dockerfile: Dockerfile

            - ./:/app

        working_dir: "/app"

            - 8080:8080

        command: ["python", ""]

Then run this command:

docker compose up  # on your system it might be 'docker-compose'