Skip to main content

Hostless File

The Hostless file (hostless.yaml) is a configuration file that allows you to define and manage your application's infrastructure as code. It provides a declarative way to configure build settings, deployment parameters, scaling rules, health checks, cron jobs, and worker processes - all from a single configuration file in your repository.

Overview

The Hostless file enables you to:

  • Version control your infrastructure: Keep your application configuration alongside your code
  • Automate deployments: Changes to the hostless file trigger automatic updates to your app configuration
  • Ensure consistency: Define your infrastructure once and apply it consistently across environments
  • Simplify app management: Configure all aspects of your app from a single file

File Location

By default, Hostless looks for a file named hostless.yaml in the root of your repository. You can customize the file path in your app settings if needed.

File Format

The Hostless file uses YAML format for configuration. Here's the complete structure:

# Build Configuration
build:
command: "npm install && npm run build" # Command to build your application
system: auto # Build system: 'auto', 'docker', or 'nixpacks'
min_cpu: 0.5 # Minimum CPU allocated for builds
max_cpu: 2 # Maximum CPU allocated for builds
min_memory: 512 # Minimum memory in MB for builds
max_memory: 2048 # Maximum memory in MB for builds

# Docker Configuration (optional)
dockerfile_path: "./Dockerfile" # Path to Dockerfile if using Docker build system

# Post-Build Command (optional)
post_build_command: "npm run migrate" # Command to run after build, before deployment

# Start Command
start_command: "npm start" # Command to start your application

# Scaling Configuration
scaling:
trigger: http_requests # Scaling trigger type
min_cpu: 0.1 # Minimum CPU per replica
max_cpu: 1 # Maximum CPU per replica
min_memory: 128 # Minimum memory in MB per replica
max_memory: 1024 # Maximum memory in MB per replica
min_replicas: 1 # Minimum number of replicas
max_replicas: 5 # Maximum number of replicas
max_http_requests_per_replica: 100 # Max concurrent requests per replica

# Health Check Configuration
health_check:
type: http # Health check type: 'http', 'tcp', or 'command'
http_path: "/health" # HTTP path for health checks (if type is http)
interval_in_seconds: 30 # Interval between health checks

# Cron Jobs (optional)
cron_jobs:
- command: "npm run cleanup" # Command to execute
schedule: "0 0 * * *" # Cron expression (daily at midnight)
timezone_utc_offset: 0 # UTC offset for timezone
cpus: 0.5 # CPU allocation for the job
memory: 256 # Memory allocation in MB
status: "active" # Job status: 'active' or 'inactive'

# Worker Processes (optional)
workers:
- name: "queue-processor" # Unique name for the worker
command: "npm run worker:queue" # Command to run the worker
min_cpu_per_replica: 0.1 # Minimum CPU per worker replica
max_cpu_per_replica: 1 # Maximum CPU per worker replica
min_memory_per_replica: 128 # Minimum memory in MB per replica
max_memory_per_replica: 512 # Maximum memory in MB per replica
replicas: 2 # Number of worker replicas

Configuration Sections

Build Configuration

The build section defines how your application is built:

FieldTypeDescriptionRequired
commandstringBuild command to executeNo
systemstringBuild system: auto, docker, or nixpacksNo
min_cpunumberMinimum CPU cores for build (0.01 - 16)No
max_cpunumberMaximum CPU cores for build (0.1 - 16)No
min_memorynumberMinimum memory in MB (128 - 32768)No
max_memorynumberMaximum memory in MB (128 - 32768)No

Deployment Configuration

FieldTypeDescriptionRequired
dockerfile_pathstringPath to Dockerfile (when using Docker build)No
post_build_commandstringCommand to run after build, before deploymentNo
start_commandstringCommand to start your applicationNo

Scaling Configuration

The scaling section controls how your application scales:

FieldTypeDescriptionRequired
triggerstringScaling trigger: http_requestsNo
min_cpunumberMinimum CPU per replica (0.01 - 16)No
max_cpunumberMaximum CPU per replica (0.1 - 16)No
min_memorynumberMinimum memory in MB per replicaNo
max_memorynumberMaximum memory in MB per replicaNo
min_replicasnumberMinimum number of replicas (1+)No
max_replicasnumberMaximum number of replicas (1+)No
max_http_requests_per_replicanumberMax concurrent requests per replicaNo

Health Check Configuration

FieldTypeDescriptionRequired
typestringHealth check type: http, tcp, or commandNo
http_pathstringHTTP endpoint path (when type is http)No
interval_in_secondsnumberSeconds between health checksNo

Cron Jobs

Each cron job in the cron_jobs array supports:

FieldTypeDescriptionRequired
commandstringCommand to executeYes
schedulestringCron expressionYes
timezone_utc_offsetnumberUTC offset (-12 to +14)Yes
cpusnumberCPU allocation (0.01 - 16)No
memorynumberMemory allocation in MBNo
statusstringJob status: active or inactiveNo

Worker Processes

Each worker in the workers array supports:

FieldTypeDescriptionRequired
namestringUnique worker nameYes
commandstringCommand to run the workerYes
min_cpu_per_replicanumberMinimum CPU per replicaYes
max_cpu_per_replicanumberMaximum CPU per replicaYes
min_memory_per_replicanumberMinimum memory in MBYes
max_memory_per_replicanumberMaximum memory in MBYes
replicasnumberNumber of replicasYes

How It Works

Automatic Sync on Deployment

When you push changes to your repository, Hostless automatically:

  1. Detects if a hostless.yaml file exists in your repository
  2. Validates the configuration
  3. Applies the configuration to your app
  4. Updates build settings, scaling rules, health checks, cron jobs, and workers accordingly

Examples

Basic Node.js Application

build:
command: "npm install"
system: auto
min_cpu: 0.5
max_cpu: 2
min_memory: 512
max_memory: 2048

start_command: "node server.js"

scaling:
min_replicas: 1
max_replicas: 3
min_cpu: 0.1
max_cpu: 1
min_memory: 256
max_memory: 1024

health_check:
type: http
http_path: "/health"
interval_in_seconds: 30

Python Application with Workers and Cron Jobs

build:
command: "pip install -r requirements.txt"
system: auto
min_cpu: 1
max_cpu: 4
min_memory: 1024
max_memory: 4096

post_build_command: "python manage.py migrate"
start_command: "gunicorn app:application --bind 0.0.0.0:$PORT"

scaling:
trigger: http_requests
min_replicas: 2
max_replicas: 10
min_cpu: 0.5
max_cpu: 2
min_memory: 512
max_memory: 2048
max_http_requests_per_replica: 50

health_check:
type: http
http_path: "/api/health"
interval_in_seconds: 20

cron_jobs:
- command: "python manage.py cleanup_old_data"
schedule: "0 2 * * *"
timezone_utc_offset: 0
cpus: 1
memory: 512
status: active

workers:
- name: "celery-worker"
command: "celery -A app worker -l info"
min_cpu_per_replica: 0.5
max_cpu_per_replica: 2
min_memory_per_replica: 512
max_memory_per_replica: 2048
replicas: 3
- name: "celery-beat"
command: "celery -A app beat -l info"
min_cpu_per_replica: 0.1
max_cpu_per_replica: 0.5
min_memory_per_replica: 256
max_memory_per_replica: 512
replicas: 1

Docker-based Application

build:
system: docker
min_cpu: 2
max_cpu: 8
min_memory: 2048
max_memory: 8192

dockerfile_path: "./Dockerfile"
start_command: "docker-entrypoint.sh"

scaling:
min_replicas: 1
max_replicas: 5
min_cpu: 1
max_cpu: 4
min_memory: 1024
max_memory: 4096

health_check:
type: tcp
interval_in_seconds: 15

Best Practices

  1. Start Simple: Begin with minimal configuration and add complexity as needed
  2. Version Control: Always commit your hostless.yaml file to your repository
  3. Test Locally: Validate your YAML syntax before committing
  4. Resource Limits: Set appropriate min/max values to control costs while ensuring performance
  5. Health Checks: Configure health checks to ensure your app stays healthy
  6. Environment Variables: Keep sensitive data in environment variables, not in the hostless file

Validation

Hostless automatically validates your configuration file for:

  • Valid YAML syntax
  • Required fields
  • Value ranges (CPU, memory, replicas)
  • Cron expression validity
  • Unique worker names

If validation fails, the deployment will be rejected with detailed error messages.

Troubleshooting

Common Issues

Validation Errors

  • Check YAML syntax using a validator
  • Ensure all required fields are present
  • Verify values are within acceptable ranges

Configuration Not Applied

  • Check deployment logs for errors
  • Ensure you have proper permissions
  • Verify the file is committed to the correct branch

Workers Not Starting

  • Ensure worker commands are correct
  • Check worker logs for errors
  • Verify resource allocations are sufficient