Self Hosting
Hatchet Lite

Hatchet Lite Deployment

To get up and running quickly, you can deploy via the hatchet-lite image. This image is designed for development and low-volume use-cases.

Prerequisites

This deployment requires Docker (opens in a new tab) installed locally to work.

Getting Hatchet Lite Running

Copy the following docker-compose.hatchet.yml file to the root of your repository:

docker-compose.hatchet.yml
version: "3.8"
name: hatchet-lite
services:
  postgres:
    image: postgres:15.6
    command: postgres -c 'max_connections=200'
    restart: always
    environment:
      - POSTGRES_USER=hatchet
      - POSTGRES_PASSWORD=hatchet
      - POSTGRES_DB=hatchet
    volumes:
      - hatchet_lite_postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d hatchet -U hatchet"]
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 10s
  hatchet-lite:
    image: ghcr.io/hatchet-dev/hatchet/hatchet-lite:latest
    ports:
      - "8888:8888"
      - "7077:7077"
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      RABBITMQ_DEFAULT_USER: "user"
      RABBITMQ_DEFAULT_PASS: "password"
      DATABASE_URL: "postgresql://hatchet:hatchet@postgres:5432/hatchet?sslmode=disable"
      DATABASE_POSTGRES_PORT: "5432"
      DATABASE_POSTGRES_HOST: "postgres"
      SERVER_TASKQUEUE_RABBITMQ_URL: amqp://user:password@localhost:5672/
      SERVER_AUTH_COOKIE_DOMAIN: localhost
      SERVER_AUTH_COOKIE_INSECURE: "t"
      SERVER_GRPC_BIND_ADDRESS: "0.0.0.0"
      SERVER_GRPC_INSECURE: "t"
      SERVER_GRPC_BROADCAST_ADDRESS: localhost:7077
      SERVER_GRPC_PORT: "7077"
      SERVER_URL: http://localhost:8888
      SERVER_AUTH_SET_EMAIL_VERIFIED: "t"
      SERVER_LOGGER_LEVEL: warn
      SERVER_LOGGER_FORMAT: console
      DATABASE_LOGGER_LEVEL: warn
      DATABASE_LOGGER_FORMAT: console
    volumes:
      - "hatchet_lite_rabbitmq_data:/var/lib/rabbitmq/mnesia"
      - "hatchet_lite_config:/config"
 
volumes:
  hatchet_lite_postgres_data:
  hatchet_lite_rabbitmq_data:
  hatchet_lite_config:

Then run docker-compose -f docker-compose.hatchet.yml up to get the Hatchet Lite instance running.

Accessing Hatchet Lite

Once the Hatchet Lite instance is running, you can access the Hatchet Lite UI at http://localhost:8888 (opens in a new tab).

By default, a user is created with the following credentials:

Email: admin@example.com
Password: Admin123!!

Generate a .env file

You can generate a .env file as follows:

cat <<EOF > .env
HATCHET_CLIENT_TOKEN="$(docker compose -f docker-compose.hatchet.yml exec hatchet-lite /hatchet-admin token create --config /config --tenant-id 707d0855-80ab-4e1f-a156-f1c4546cbf52 | xargs)"
HATCHET_CLIENT_TLS_STRATEGY=none
EOF
🪓

You can also generate an API token by logging in and navigating to the "General" settings page, clicking on the "API Tokens" tab, and then clicking "Create API Token".

Run your first worker

Make sure you have the following dependencies installed:

pip install python-dotenv
pip install hatchet-sdk

We are using python-dotenv (opens in a new tab) to load the environment variables from a .env file. This isn't required, and you can use your own method to load environment variables.

Create a worker.py file with the following contents:

worker.py
from hatchet_sdk import Hatchet
from dotenv import load_dotenv
 
load_dotenv()
 
hatchet = Hatchet(debug=True)
 
@hatchet.workflow(name="first-python-workflow",on_events=["user:create"])
class MyWorkflow:
    @hatchet.step()
    def step1(self, context):
        return {
            "result": "success"
        }
 
worker = hatchet.worker('first-worker')
worker.register_workflow(MyWorkflow())
 
worker.start()

Open a new terminal and start the worker with:

python3 worker.py

Run your first workflow

The worker is now running and listening for steps to execute. You should see your first worker registered in the Workers tab of the Hatchet dashboard:

Quickstart 1

You can now trigger your first workflow by navigating to the Workflows tab, selecting your workflow, and clicking the top right "Trigger workflow" button:

Quickstart 2

That's it! You've successfully deployed Hatchet and run your first workflow.