Configuration
Platformatic Runtime is configured with a configuration file. It supports the use of environment variables as setting values with environment variable placeholders.
Configuration Files
The Platformatic CLI automatically detects and loads configuration files found in the current working directory with the file names listed here.
Alternatively, you can use the --config
option to specify a configuration file path for most platformatic runtime
CLI commands. The configuration examples in this reference use the JSON format.
Supported File Formats
For detailed information on supported file formats and extensions, please visit our Supported File Formats and Extensions page.
Settings
Configuration settings containing sensitive data should be set using environment variable placeholders.
The autoload
and services
settings can be used together, but at least one
of them must be provided. When the configuration file is parsed, autoload
configuration is translated into services
configuration.
autoload
The autoload
configuration is intended to be used with monorepo applications.
autoload
is an object with the following settings:
path
(required,string
) - The path to a directory containing the microservices to load. In a traditional monorepo application, this directory is typically namedpackages
.exclude
(array
ofstring
s) - Child directories insidepath
that should not be processed.mappings
(object
) - Each microservice is given an ID and is expected to have a Platformatic configuration file. By default, the ID is the microservice's directory name, and the configuration file is expected to be a well-known Platformatic configuration file.mappings
can be used to override these default values.id
(required,string
) - The overridden ID. This becomes the new microservice ID.- **
config
(string
) - The overridden configuration file. name. This is the file that will be used when starting the microservice. useHttp
(boolean
) - The service will be started on a random HTTP port on127.0.0.1
, and exposed to the other services via that port and on default, it is set tofalse
.workers
(number
) - The number of workers to start for this service. If the service is the entrypoint or if the runtime is running in development mode this value is ignored and hardcoded to1
.health
(object): Configures the health check for each worker of the service. It supports all the properties also supported in the runtime health property. The values specified here overrides the values specified in the runtime.preload
(string
orarray
ofstring
s): A file or a list of files to load before the service code.nodeOptions
(string
): TheNODE_OPTIONS
to apply to the service. These options are appended to any existing option.
preload
The preload
configuration is intended to be used to register
Application Performance Monitoring (APM) agents. preload
should contain
a path or a list of paths pointing to a CommonJS or ES module that is loaded at the start of
the app worker thread.
services
services
is an array of objects that defines the microservices managed by the
runtime. Each service object supports the following settings:
id
(required,string
) - A unique identifier for the microservice. When working with the Platformatic Composer, this value corresponds to theid
property of each object in theservices
section of the config file. When working with client objects, this corresponds to the optionalserviceId
property or thename
field in the client'spackage.json
file if aserviceId
is not explicitly provided.path
(required,string
) - The path to the directory containing the microservice. It can be omitted ifurl
is provided.url
(required,string
) - The URL of the service remote GIT repository, if it is a remote service. It can be omitted ifpath
is provided.gitBranch
(string) - The branch of the service to resolve.config
(string
) - The configuration file used to start the microservice.useHttp
(boolean
) - The service will be started on a random HTTP port on127.0.0.1
, and exposed to the other services via that port, on default it is set tofalse
. Set it totrue
if you are using @fastify/express.workers
(number
) - The number of workers to start for this service. If the service is the entrypoint or if the runtime is running in development mode this value is ignored and hardcoded to1
.health
(object): Configures the health check for each worker of the service. It supports all the properties also supported in the runtime health property. The values specified here overrides the values specified in the runtime.envfile
(string
) - The path to an.env
file to load for the service.env
(object
) - An object containing environment variables to set for the service. Values set here takes precedence over values set in theenvfile
.sourceMaps
(boolean
) - Iftrue
, source maps are enabled for the service. Default:false
.packageManager
(string
) - The package manager to use when using theinstall-dependencies
or theresolve
commands ofplt
orwattpm
. Default is to autodetect it, unless it is specified via command line.preload
(string
orarray
ofstring
s): A file or a list of files to load before the service code.nodeOptions
(string
): TheNODE_OPTIONS
to apply to the service. These options are appended to any existing option.
If this property is present, then the services will not be reordered according to the
getBootstrapDependencies
function and they will be started in the order they are defined in
the configuration file.
web
An alias for services
. If both are present, their content will be merged.
env
An object containing environment variables to set for all services in the
runtime. Any environment variables set in the env
object will be merged with
the environment variables set in the envfile
and env
properties of each
service, with service-level environment variables taking precedence.
sourceMaps
If true
, source maps are enabled for all services. Default: false
. This setting can be overridden at the service level.
resolvedServicesBasePath
The base path, relative to the configuration file to store resolved services. Each service will be saved in {resolvedServicesBasePath}/{id}
. Default: external
.
entrypoint
The Platformatic Runtime's entrypoint is a microservice that is exposed
publicly. This value must be the ID
of a service defined via the autoload
or
services
configuration.