Project configuration
Hosty CLI builds and deploys a project from its configuration file, .hosty/hosty.yaml in the root of the project. This page describes every setting of the file. For complete files of common frameworks, see the examples for Next.js, Django, WordPress and Drupal.
Before you start
- The project must be in a Git repository. Hosty CLI tags the images of an application with the Git hashes of its files, so it builds new images only when the code changes. Only committed changes count: commit before you build.
- The admins give you the name of the cluster, its region and the name of the project.
- Every application is built into images from its own folder (appRoot). Files outside of it don't get into the images.
A minimal file
clusterName: <cluster>
clusterRegion: eu-west-2
projectName: example
applications:
backend:
type: php:nginx
appRoot: ./drupal
nginx:
version: "1.30"
php:
version: "8.4"Hosty CLI checks the file before every command and stops with an error that names the wrong setting.
Project settings
Setting | Required | Description |
|---|---|---|
clusterName | Yes | Name of the cluster. Given by the admins. |
clusterRegion | Yes | AWS region of the cluster, i.e. eu-west-2. Given by the admins. |
projectName | Yes | Name of the project. Up to 12 characters: lowercase letters, digits and -. Given by the admins. |
applications | Yes | The applications of the project. Usually there's one, but you can have several, i.e. a backend and a frontend. |
services.redis | No | Redis for all applications of the project. See Redis. |
backup | No | When production is backed up, and whether partial dumps are made. See Backups and import. |
import | No | How long the first deployment of an environment waits for the import of the backups. See Backups and import. |
Applications
Each key under applications is the name of an application: up to 12 characters, lowercase letters and digits only. The name goes into the domains of environments, the names of databases and the tokens like {{ backend.host.0 }}, so pick it once and keep it.
Application types
type | Containers | Where the code is | Port of the application |
|---|---|---|---|
php:nginx | PHP-FPM and nginx | /var/www/html | 9000 (php-fpm) |
php:apache | PHP-FPM and Apache | /var/www/html | 9000 (php-fpm) |
python:nginx | Python and nginx | /usr/src/app | 8080, or python.port |
python | Python only, without a web server and domains | /usr/src/app | none |
node | Node.js, without a web server | /usr/src/app | 3000 |
Hosty builds the images from the Wodby images: wodby/php, wodby/nginx, wodby/apache, wodby/python (its -dev flavour, which has the libraries for database clients) and wodby/node. Their README files list the environment variables each image understands.
The load balancer checks /.healthz of every pod and sends requests only to healthy ones. nginx and Apache answer it for PHP and Python applications. A Node.js application has no web server in front of it, so it must answer /.healthz itself, with 200 or 204.
Application settings
Setting | Default | Description |
|---|---|---|
type | Required | One of the types above. |
appRoot | Required | Folder of the application, relative to the root of the project, i.e. ./drupal. It's the build context of the images and becomes the folder of the code in the containers. |
extraBuildDependencies | None | Other files or folders, relative to the root of the project, whose changes build new images, i.e. ./.circleci. They only change the tag of the images: their files don't get into the images. |
readOnlyCode | true | Whether the code is read-only in the containers. See Read-only code. |
ingress | true (false for python) | false for an application that serves no requests, i.e. a scheduler. It then has no domains, no web server and no load balancer, and can't have hosts or {{ <application>.host.N }} tokens. |
replicas | Autoscaling | A fixed number of pods, from 1 to 10, on every environment. See Resources and scaling. |
hosts | Generated on development environments, required on production | Domains of the application. See Domains. |
database | | Settings of the database, which PHP and Python applications always have. See Database. |
search | None | An OpenSearch user and index prefix. See Search. |
crontab | None | Cron jobs. See Cron jobs. |
persistentStorages | None | Folders that stay writable and keep their files between deployments. See Persistent storages. |
overrides | None | Settings for particular environments. See Overrides. |
php, python, node, nginx, apache | Required | Settings of each container of the type. See below. |
Container settings
Each container of the type has a section named after it: php and nginx for php:nginx, node for node, and so on. A section has these settings:
Setting | Containers | Description |
|---|---|---|
version | All | Required. The version of the software, from the table of supported versions. Write it in quotes: without them, YAML reads 1.30 as the number 1.3. |
tag | All | Pins the release of the Wodby image. See Image releases. |
environmentVariables | All | Variables of the container. Names are uppercase letters, digits and _. Values must be strings, so quote numbers and booleans: PHP_FPM_PM_MAX_CHILDREN: "30". See Environment variables. |
environmentFiles | All | Files with more variables, relative to the root of the project, i.e. ./.env.secrets. See Sensitive environment variables. |
hooks.build | php, python, node | Shell script that builds the application in the image, i.e. composer install. It stops at the first command that fails, and the build fails with it. |
hooks.run | python, node | Required for these two. The command that starts the application, i.e. npm run start. |
port | python | Port the Python application listens on. 8080 by default. Node.js applications always listen on 3000: Hosty CLI refuses any other port, as the load balancers and the network policies reach only that one. |
healthCheck.command | python | A command that checks the health of the container instead of its port, i.e. for a worker without a port. The container is healthy while the command exits with 0. |
The build hook runs as the user of the image, in the folder of the code, with the environment variables of the container. Add || true after a command that may fail on purpose. The caches of Composer, pip, npm and yarn are kept between builds, so a build doesn't download all packages again.
Supported versions
Container | Versions |
|---|---|
php | 8.2, 8.3, 8.4, 8.5 |
python | 3.11, 3.12, 3.13, 3.14, 3.15 |
node | 22, 24, 26 |
nginx | 1.30, 1.31 |
apache | 2.4 |
Redis | 7 (set by Hosty) |
Hosty supports the versions that Wodby still rebuilds with security fixes. When a version is dropped, deployments with it fail until you update hosty.yaml.
Image releases
Without a tag, every build takes the latest release of the Wodby image for the version, i.e. wodby/php:8.4.27-r1 for version: "8.4". So a new deployment picks up the security fixes of PHP, nginx and the rest. Hosty also checks that the release it found has the latest version of the software: when Wodby names its releases in a new way that Hosty doesn't recognise yet, the build stops instead of using an old release.
tag pins a release of the version, i.e. tag: r10 for wodby/php:8.4-r10. For Python the tag goes after the flavour: tag: r7 of Python 3.12 is wodby/python:3.12-dev-r7. Hosty checks that the tag exists on Docker Hub, refuses latest, and skips the check of the latest release.
A pinned image gets no security fixes. Pin a tag only as a workaround, i.e. when a new release breaks your site or Hosty can't find the latest release, and remove it as soon as you can.
Read-only code
The code of PHP and Node.js applications is owned by root in the images, so the processes of the application can't change it. If an attacker runs code through a vulnerability of the site, they can't leave a backdoor in it. Only the persistent storages are writable.
The image is built in two stages, and the second one gets only the folder of the application. Files that the build hook puts outside of it are left out.
If your application writes into its own code at runtime, or needs files from outside its folder, turn it off:
applications:
frontend:
readOnlyCode: falsePython applications have writable code for now, as their packages are installed outside of the folder of the application.
Database
PHP and Python applications get a database on the cluster's database server (Aurora MySQL or PostgreSQL, whichever the cluster has), with its own name and user on each environment. Node.js applications have no database. Your application connects to it with the DB_* environment variables.
database:
type: mysql
excludeTablesFromImportOnDevEnvs:
- cache%
- sessionsSetting | Description |
|---|---|
type | mysql or postgresql. Optional: it must match the database of the cluster, and the deployment stops if it doesn't. |
excludeTablesFromImportOnDevEnvs | Tables whose data is left out of the partial backups, which development environments are created from. Their structure stays. % matches any characters, i.e. cache%. List the tables with personal data and the caches. |
extensions | PostgreSQL only. Extensions to create in the database on import, i.e. [postgis], in addition to those of the backup. |
from | The name of another application of the project, whose database this application uses: the same database, user and password. The import, the backups and the deletion of the database belong to that application, so from can't be combined with the other settings. |
On MySQL, applications connect with the database account of the project: <project>_production on production and <project>_development on development environments. Production databases are named <project>_production_<application>, development ones <project>_development_<environment>_<application>.
Search
search gives each environment of a PHP or Python application a user of the cluster's OpenSearch domain:
search:
type: opensearchThe user can work only with the indices whose names start with OPENSEARCH_INDEX_PREFIX, so your application must name its indices with it. Indices aren't copied between environments: rebuild them from the data, i.e. after the first deployment. The cluster needs OpenSearch turned on by the admins, otherwise the deployment stops with an error.
Cron jobs
crontab:
enabled: true
jobs:
- name: drupal-cron
schedule: "*/15 * * * *"
command: drush cron
timeout: 600
memory: 512Setting | Description |
|---|---|
enabled | Cron jobs run on production by default, and on development environments only with enabled: true. enabled: false turns them off everywhere, i.e. on a production that isn't the live site yet. |
jobs[].schedule | Required. Usual crontab syntax, in UTC. |
jobs[].command | Required. Runs with /bin/sh -c in the folder of the code. |
jobs[].name | Optional. Names the job in the cluster: up to 20 characters, lowercase letters, digits and -. Without it, the job is named by a hash of its schedule and command. Two jobs can't have the same name, or the same schedule and command. |
jobs[].timeout | Optional. Time limit of a run, in seconds. |
jobs[].memory | Optional. Memory a run asks for, in MiB, from 64. 256 by default. On production it can't be more than the memory limit of the application. |
Each run is a pod of its own, from the image of the application, with its environment variables, database, Redis, search and storages. A deployment doesn't stop runs that are going. Runs go to the development servers, to keep the load off production. The run hook of a Python application doesn't run before a cron job, so the command must prepare what it needs itself.
Persistent storages
The files of a storage live on a shared file system (EFS), are shared by all pods of the environment and stay between deployments. On production they are backed up with the database.
persistentStorages:
public:
path: web/sites/default/files
syncArgsForDevEnvs: --exclude=styles/* --exclude=css/* --exclude=js/*
private: private- The name is up to 16 characters, lowercase letters and digits.
- path is relative to appRoot, without ./.
- syncArgsForDevEnvs are extra arguments of aws s3 sync for the import of the files into new development environments, i.e. to leave out generated images.
- Without syncArgsForDevEnvs, you can write a storage as name: path.
The application gets the absolute path of each storage in FILES_<NAME>_PATH, i.e. FILES_PUBLIC_PATH.
Domains
By default, each development environment of an application gets one domain: <application>-<environment>.<project>.<hosted zone>. Production has no such domain: every application with ingress needs its own domains in hosts, in an override of production, or Hosty CLI refuses to build and deploy production. hosts replaces the generated domain with your list:
overrides:
- condition:
environments: [production]
hosts:
- example.com
- www.example.comWith hosts, the application has only the listed domains: the generated one is gone. Every domain needs an SSL certificate first. See Adding a custom domain.
Overrides
overrides changes the settings of an application on some environments:
overrides:
- condition:
environments: [stage]
php:
environmentVariables:
APP_MODE: stage
- condition:
environments: [production]
negate: true
crontab:
enabled: false- condition.environments is a list of names of environments. Write them in lowercase, with - instead of _, as Hosty names environments.
- negate: true applies the override to all environments except the listed ones.
- An override has the same structure as the application. Hosty merges it into the settings: maps are merged key by key, and lists, such as hosts or crontab.jobs, are replaced whole.
- All overrides that match the environment apply, in the order of the list.
Tokens
Values in hosty.yaml can use tokens, which the build and deploy commands replace, such as {{ environmentName }} or {{ backend.host.0 }}. See Environment variables.
Backups and import
Production is backed up three times a day: a full dump of the database, a partial dump without the data of the tables in excludeTablesFromImportOnDevEnvs, and a copy of the persistent storages. Development environments have no backups.
backup:
# Hours of the day in UTC, from 0 to 23. [0, 8, 16] by default.
hours: [2]
# false to make only full dumps. true by default.
partial: true
import:
# Minutes, from 30 to 1440. 30 by default.
timeout: 240- backup.hours: the minute of the hour is picked for each application, so that the backups of projects don't all start at once.
- backup.partial: false suits a project without development environments, or whose partial dump is the same as the full one. New development environments are created from partial dumps, so without them their deployment stops with an error.
- The first deployment of an environment imports the latest backups: production imports the full dump, development environments the partial one. import.timeout sets how long that deployment waits for the import; raise it for a large database. Your CI job needs a timeout at least as long.
Redis
services.redis runs Redis 7 on each environment, for all applications of the project. They get the REDIS_* environment variables.
services:
redis:
# Required. Memory for the data in MB, from 32 to 8192.
size: 256
# Saves the data to disk, so it survives restarts. true by default.
persistence: false
# What Redis evicts when it's full. allkeys-lru by default.
maxmemory_policy: allkeys-lruFor a cache, persistence: false is faster: Redis starts empty right away, instead of loading the data back. maxmemory_policy takes the policies of Redis: noeviction, allkeys-lru, allkeys-lfu, allkeys-random, volatile-lru, volatile-lfu, volatile-random and volatile-ttl. Keep allkeys-lru for Drupal, which stores cache items without expiration that volatile-* policies never evict.
Redis restarts on a deployment only for a new version of Redis.
Resources and scaling
You don't set CPU and memory in hosty.yaml. Hosty sets them by the environment:
- Development environments run one pod of each application, with small requests of CPU and memory and no limits.
- Production runs at least two pods, on different servers, and adds pods under load, up to the number of production servers. A PHP or Python container asks for 200m CPU and 1 GiB (PHP) or 800 MiB (Python) of memory, and is restarted if it grows above 8 GiB or half the memory of a server, whichever is less. A Node.js container asks for 250m CPU and 500 MiB.
- PHP on production runs 20 php-fpm workers per pod. Set PHP_FPM_PM_MAX_CHILDREN in the variables of php to change it.
- replicas runs a fixed number of pods on every environment, without autoscaling. With replicas: 1, a new pod starts only after the old one has stopped, so two pods never run at once, i.e. for a scheduler.
Full example
An annotated file with most of the settings. The second application, worker, is a Python script without a web server that uses the database of backend.
clusterName: <cluster>
clusterRegion: eu-west-2
projectName: example
services:
redis:
size: 256
persistence: false
backup:
hours: [1, 13]
import:
timeout: 120
applications:
backend:
type: php:nginx
appRoot: ./drupal
# Build new images when the patches change too.
extraBuildDependencies:
- ./patches
nginx:
version: "1.30"
environmentVariables:
# The code is in /var/www/html, so the web root is /var/www/html/<folder>.
NGINX_SERVER_ROOT: /var/www/html/web
NGINX_VHOST_PRESET: drupal10
php:
version: "8.4"
# Pin a release only as a workaround:
# tag: r10
environmentVariables:
DRUSH_OPTIONS_URI: "https://{{ backend.host.0 }}"
APP_MODE: development
environmentFiles:
- ./.env.secrets
hooks:
build: |
composer install --no-interaction --no-dev
database:
excludeTablesFromImportOnDevEnvs:
- cache%
- sessions
- users_field_data
# Only if the cluster has OpenSearch.
search:
type: opensearch
crontab:
jobs:
- name: drupal-cron
schedule: "*/15 * * * *"
command: drush cron
persistentStorages:
public:
path: web/sites/default/files
syncArgsForDevEnvs: --exclude=styles/* --exclude=css/* --exclude=js/*
private: private
tmp: tmp
overrides:
- condition:
environments: [stage]
php:
environmentVariables:
APP_MODE: stage
crontab:
enabled: true
- condition:
environments: [production]
hosts:
- example.com
- www.example.com
php:
environmentVariables:
APP_MODE: production
worker:
type: python
appRoot: ./worker
replicas: 1
database:
from: backend
python:
version: "3.13"
hooks:
build: |
pip install -r requirements.txt
run: |
python worker.py
healthCheck:
command: test -f /tmp/worker-aliveHosty CLI reads the file from .hosty/ by default. To keep it in another folder of the project, set the HOSTY_CONFIG_FOLDER environment variable of the Hosty CLI container to that folder.