For developers
Project configuration
2min
Hosty CLI requires projects to use Git as a version control system. Git hashes are used to calculate build hash of the code to avoid rebuild of Docker images if hash does not change.
Hosting configuration for a project is represented by hosty.yaml file located in .hosty folder relative to the project's root (.hosty/hosty.yaml).
Below you can find a full example of configuration file with list of configuration options:
YAML
1# Name of the hosting cluster. Provided by hosting administrators.
2clusterName: unicorn
3# AWS region name of the hosting cluster. Provided by hosting administrators.
4clusterRegion: eu-west-2
5# Name of the project. Provided by hosting administrators.
6projectName: example
7# List of project services.
8services:
9 # Adds a Redis service to the project. In this case,
10 # each application will have the following env variables:
11 # - REDIS_HOST
12 # - REDIS_PORT
13 # - REDIS_PASSWORD
14 redis:
15 # Size (in MB) of the Redis storage.
16 size: 256
17
18# List of project applications (usually there's only 1, but multiple applications are supported too).
19applications:
20 # Arbitrary name of the application.
21 backend:
22 # Allowed application types:
23 # - php:nginx
24 # - php:apache
25 # - node
26 # - python:nginx
27 type: php:nginx
28 # Path to the application folder relative to the project root.
29 appRoot: ./drupal
30 # List of additional files or folders to track to make Hosty aware that Docker images for
31 # the environment have to be rebuilt if these files have been changed and committed to the git repo.
32 # By default, only "appRoot" folder is tracked for changes.
33 # Specify a list of paths relative to the project root.
34 extraBuildDependencies:
35 - ./.circleci
36
37 # Nginx web server configuration.
38 # Relevant only when "php:nginx" application type is chosen.
39 # For nginx, we use https://github.com/wodby/nginx Docker image,
40 # so you can check the repository to see the full list of configuration
41 # options through environment variables.
42 nginx:
43 # Supported versions can be found on this page https://github.com/wodby/nginx?tab=readme-ov-file#docker-images.
44 version: 1.25
45 # Specify a tag of a Docker image to use.
46 # Important note: Hosty automatically picks up the latest tag on deployment,
47 # so for security reasons, we highly don't recommend hardcoding a tag version.
48 # However, if a certain tag version of the Docker image causes issues, it
49 # can be used as a temporary workaround until the issue with Docker image is solved.
50 # List of supported tags can be found at https://github.com/wodby/nginx/tags.
51 #tag: 5.38.0
52 # Environment variables for nginx container.
53 # You can find a full list of variables at https://github.com/wodby/nginx?tab=readme-ov-file#environment-variables.
54 environmentVariables:
55 # The application root folder is always mapped to "/var/www/html", so
56 # specify here an absolute path to the web server root by replacing
57 # your "appRoot" with "/var/www/html".
58 NGINX_SERVER_ROOT: /var/www/html/web
59 # For Drupal and WordPress, the Docker image has pre-defined presets
60 # for improved developer experience and security.
61 NGINX_VHOST_PRESET: drupal10
62
63 # Apache web server configuration.
64 # Relevant only when "php:apache" application type is chosen.
65 # For apache we use https://github.com/wodby/apache Docker image,
66 # so you can check the repository to see the full list of configuration
67 # options through environment variables.
68 apache:
69 # Supported versions can be found on this page https://github.com/wodby/apache?tab=readme-ov-file#docker-images.
70 version: 2.4
71 # Specify a tag of a Docker image to use.
72 # Important note: Hosty automatically picks up the latest tag on deployment,
73 # so for security reasons we highly don't recommend hardcoding a tag version.
74 # However, if a certain tag version of the Docker image would cause issues, it
75 # can be used as a temporary workaround until the issue with Docker image is solved.
76 # List of supported tags can be found at https://github.com/wodby/apache/tags.
77 #tag: 4.14.3
78 # Environment variables for apache container.
79 # You can find full list of variables at https://github.com/wodby/apache?tab=readme-ov-file#environment-variables.
80 environmentVariables:
81 # The application root folder is always mapped to "/var/www/html", so
82 # specify here absolute path to the web server root by replacing
83 # your "appRoot" with "/var/www/html".
84 APACHE_DOCUMENT_ROOT: /var/www/html/web
85
86 # PHP configuration.
87 # Relevant only when "php:nginx" or "php:apache" application type is chosen.
88 # For PHP, we use https://github.com/wodby/php Docker image,
89 # so you can check the repository to see the full list of configuration
90 # options through environment variables.
91 php:
92 # Supported versions can be found on this page https://github.com/wodby/php?tab=readme-ov-file#docker-images.
93 version: 8.3
94 # Specify a tag of a Docker image to use.
95 # Important note: Hosty automatically picks up the latest tag on deployment,
96 # so for security reasons, we highly don't recommend hard coding a tag version.
97 # However, if a certain tag version of the Docker image causes issues, it
98 # can be used as a temporary workaround until the issue with Docker image is solved.
99 # List of supported tags can be found at https://github.com/wodby/php/tags.
100 #tag: 4.52.2
101 # Environment variables for php container.
102 # You can find a full list of variables at https://github.com/wodby/php?tab=readme-ov-file#environment-variables.
103 environmentVariables:
104 # Environment variables support placeholders for several
105 # global variables available at deployment:
106 # - {{ projectName }}
107 # - {{ clusterName }}
108 # - {{ environmentName }}
109 # Also, it supports several applications-specific placeholders.
110 # You need to replace $applicationName with the actual name of your application
111 # specified in this hosty.yaml file.
112 # - {{ $applicationName.name }}
113 # Replace $index with the index of host you need to use.
114 # By default, there's just 1 host per application, so the $index is 0.
115 # If you add more hosts to the application, then you can access their placeholders
116 # by increasing $index value.
117 # - {{ $applicationName.host.$index }}
118 BACKEND_HOST: "{{ backend.host.0 }}"
119 APPLICATION_MODE: development
120 # Path to key/value .env files with environment variables.
121 # Path is relative to the project root.
122 environmentFiles:
123 - ./.env.secrets
124 # Script to build app dependencies from sources.
125 hooks:
126 build: |
127 set -eu
128 composer install --no-interaction
129
130 # Adds a database to the application.
131 database:
132 # Currently only mysql database type is supported.
133 type: mysql
134 # List of table names to exclude content from
135 # when importing database backup into development environments.
136 # Use "%" wildcard symbol to add all table names matching the pattern.
137 # The hosting makes 2 types of backup: full and partial.
138 # Full backup contains the exact snapshot of the database "as is".
139 # Partial backup contains backup with content excluded from tables
140 # listed below.
141 # Partial backup is used to spin up all development environments.
142 # It is recommended to exclude cache tables and tables with personal
143 # identifiable information for faster environments spin up and security reasons.
144 excludeTablesFromImportOnDevEnvs:
145 - cache%
146 - sessions
147 - user%
148
149 # List of cron jobs.
150 # Schedule conforms with the usual crontab syntax.
151 # Cron jobs are disabled on development environments by default.
152 crontab:
153 enabled: true
154 jobs:
155 - schedule: "15 */6 * * *"
156 command: drush cron
157
158 # List of persistent file storages mounted to the application.
159 persistentStorages:
160 # Arbitrary name of the storage.
161 public:
162 # Path must be relative to the application root (appRoot) and should not include leading "./".
163 path: web/sites/default/files
164 # Optional list of arguments to use when importing files from s3 backup to a new
165 # development environments using "aws s3 sync" command.
166 syncArgsForDevEnvs: --exclude=styles/* --exclude=css/* --exclude=js/*
167 # Arbitrary name of the storage.
168 private:
169 # Path must be relative to the application root (appRoot) and should not include leading "./".
170 path: private
171 # Optional list of arguments to use when importing files from s3 backup to a new
172 # development environments using "aws s3 sync" command.
173 syncArgsForDevEnvs: --exclude=twig/*
174 # If you don't need to use "syncArgsForDevEnvs", then you can specify
175 # persistent storage in shorter format as "<storageName>: <pathRelativeToAppRoot>", like on the example below.
176 tmp: tmp
177
178 # List of host names (domains) assigned to the environment.
179 # See "overrides" section for an example how to assign a real domain name to a particular environment.
180 #hosts:
181 # By default, the hosting automatically assigns a host name based on the following pattern:
182 # - "{{ $applicationName.name }}-{{ environmentName }}.{{ projectName }}.{{ hostedZone }}"
183 # For example:
184 # - "{{ drupal.name }}-{{ environmentName }}.{{ projectName }}.{{ hostedZone }}"
185
186 # Configuration overrides for specific environments.
187 overrides:
188 # At the moment, we support only a list of environment names
189 # as conditions for overrides.
190 # Below is an example override for the stage environment.
191 - condition:
192 # The list of environments this overrides applies to.
193 environments: [ stage ]
194 # The rest of the override uses the same hierarchy as the
195 # default application configuration, so you can override
196 # whatever you wish.
197 php:
198 environmentVariables:
199 APPLICATION_MODE: staging
200
201 # At the moment, we support only a list of environment names
202 # as conditions for overrides.
203 # Below is an example override for the production environment.
204 - condition:
205 # The list of environments this overrides applies to.
206 environments: [ production ]
207 # Optional setting to reverse the logic of condition to apply.
208 # If set to "true", then the override will be applied to all environments
209 # apart from the production environment.
210 negate: false
211 # Assign a custom domain name to the application.
212 # See "Adding a custom domain" documentation page for more details.
213 hosts:
214 - example.com
215 # The rest of the override uses the same hierarchy as the
216 # default application configuration, so you can override
217 # whatever you wish.
218 php:
219 environmentVariables:
220 APPLICATION_MODE: production
221 # Specify a new cron schedule different from the default one
222 # for all other environments.
223 crontab:
224 #enabled: true
225 jobs:
226 - schedule: "0 */1 * * *"
227 command: drush cron
228