deploy4j Configuration

Configuration is read first from the config/deploy.yml.

Each configuration file is processed as a thymeleaf template, so you can use variables and conditionals in the configuration.

An environment variable can be accessed with the env.get() method, e.g.:

service: [(${env.get("DYNAMIC_SERVICE_NAME")})]
image: [(${env.get("DYNAMIC_IMAGE_NAME", "DEFAULT_IMAGE_NAME")})]

Destinations

When running commands, you can specify a destination with the -d flag, e.g. deploy4j deploy -d staging.

In that case the configuration will also be read from config/deploy.staging.yml and merged with the base configuration.

Extensions

deploy4j will ignore unrecognized keys in the configuration file.

You can declare a configuration block using YAML anchors and aliases to avoid repetition.

You can prefix a configuration section with x- to indicate that it is an extension.

Example configuration

# The service name
# This is a required value. It is used as the container name prefix.
service: myapp

# The Docker image name
#
# The image will be pushed to the configured registry.
image: my-image

# Labels
#
# Additional labels to add to the container
labels:
  my-label: my-value

# Additional volumes to mount into the container
volumes:
  - /path/on/host:/path/in/container:ro

# Registry
#
# The Docker registry configuration, see deploy4j docs registry
registry:
  ...

# Servers
#
# The servers to deploy to, optionally with custom roles, see deploy4j docs servers
servers:
  ...

# Environment variables
#
# See deploy4j docs env
env:
  ...

# Path to hooks, defaults to `.deploy4j/hooks`
# See http://localhost:4000/deploy4j/hooks/overview for more information
hooks_path: /user_home/deploy4j/hooks

# Secrets path
# 
# Path to secrets, defaults to .deploy4j/secrets. deploy4j will look for <secrets_path>-common and <secrets_path> (or <secrets_path>.<destination> when using destinations):
secrets_path: /user_home/deploy4j/secrets

# Require destinations
#
# Whether deployments require a destination to be specified, defaults to `false`
require_destination: true

# The primary role
#
# This defaults to `web`, but if you have no web role, you can change this
primary_role: workers

# Allowing empty roles
#
# Whether roles with no servers are allowed. Defaults to `false`.
allow_empty_roles: false

# Stop wait time
#
# How long we wait for a container to stop before killing it, defaults to 30 seconds
stop_wait_time: 60

# Retain containers
#
# How many old containers and images we retain, defaults to 5
retain_containers: 3

# Minimum version
#
# The minimum version of deploy4j required to deploy this configuration, defaults to nil
minimum_version: 1.3.0

# Readiness delay
#
# Seconds to wait for a container to boot after is running, default 7
# This only applies to containers that do not specify a healthcheck
readiness_delay: 4

# Run directory
#
# Directory to store deploy4j runtime files in on the host, default `.deploy4j`
run_directory: /etc/deploy4j

# SSH options
#
# See deploy4j docs ssh
ssh:
  ...

# Accessories
#
# Additionals services to run in Docker, see deploy4j docs accessory
accessories:
  ...

# Traefik
#
# The Traefik proxy is used for zero-downtime deployments, see deploy4j docs traefik
traefik:
  ...

# Boot options
#
# See deploy4j docs boot
boot:
  ...

# Healthcheck
#
# Configuring healthcheck commands, intervals and timeouts, see deploy4j docs healthcheck
healthcheck:
  ...

# Logging
#
# Docker logging configuration, see deploy4j docs logging
logging:
  ...

# Spring Boot
#
# Spring Boot specific configuration, see deploy4j docs spring-boot
spring_boot:
  ...