You can create custom stacks by defining one via template or by forking stacks provided by Wodby.

Stack template is a YML defining services, it's basically a simplified and limited version of kubernetes schema in a format very close to docker compose.

Stacks provided by Wodby (including forks) may have additional configurations not covered by templates.

Service configuration reference

This section contains a list of all configuration options supported by a service definition.

memory

You can specify memory limits and requests for a container in the following formats:

128 - Request 128Mb of memory.
512:1024 - Request 512Mb of memory. Limit 1Gb of memory.

Limit is a maximum memory (in megabytes) available for a container. When a container exceeds this limit, it will be terminated (and automatically started again). Request defines how much memory must be available on a server to start this container (used in clusters).

cpu

You can specify CPU limits and requests for a container in the following formats:

1000 - Request 1 Core.
1500 - Request 1.5 Core.
650 - Request 0.65 Core.
200:250 - Request 0.2 Core. Limit 0.25 Core.

Minimum value is 100.

Limit is a # of CPU cores (1000 for 1 core) available for a container. When a container exceeds this limit, it will be terminated (and automatically started again). Request defines how many CPU cores must be available on a server to start this container (used in clusters).

ports

Expose ports for a container in the format [PUBLIC_PORT::BUNDLE_PORT:CONTAINER_PORT].

Examples:

  • Map container's port 8080 to 80 for other containers within a stack.services
services:
  backend:
      image: example/backend
      ports:
          - "80:8080"
  • Same as 8080:8080 
8080
  • Map port 8080  to a public port within the range 31222-32222 
auto::8080
  • Map port 8080  to a public port 80 , edge  is a reverse proxy handling 80  and 443  ports. A short technical domain *.wod.by  will be generated for the first public port exposed via edge
edge::8080
  • Map port 8080  to a public port 32223 
32223::8080
  • Map port 8080  to port 80  both public and within a stack
edge::80:8080
  • Map port 8080  to port 80  within a stack, assign a public port automatically
auto::80:8080
  • Map port 8080  to port 80  within a stack, assign to a public port 32223
32223::80:8080

check-ready

deployment

security_context

Global Volumes

You can define global volumes and use them in services under volumes. We recommend using ./ as a host path to mount volumes which is an equals /srv/wodby/instances/<Instance UUID>.

Example:

services:
    myapp:
        image: example/myapp
        ports:
            - 'edge::80/tcp'
        volumes:
            - 'docroot:/var/www'
            - 'db:/var/www'
volumes:
    docroot:
        path: ./docroot
    db:
        path: ./db

Variable substitution

You can define variables and substitute them in services under environment.

Example:

services:
    backend:
        image: example/backend
        ports:
            - 'edge::80/tcp'
        environment:
            username: '%user'
            password: '%pass'

variables:
    user: 'admin'
    pass: 'auto:password:64'

Examples

services:
    db:
        image: mysql
        environment:
            MYSQL_ROOT_PASSWORD: '%db_password'
        volumes:
            - './mysql:/var/lib/mysql'
        deployment:
            strategy: recreate            
    php:
        image: php
        environment:
            DB_USER: root
            DB_PASSWORD: '%db_password'
        memory: '512:1024'
        cpu: '900'
        security_context:
            capabilities:
                add:    
                    - SYS_PTRACE
                drop:
                    - SYS_ADMIN
    nginx:
        image: nginx
        ports:
            - "edge::80:80"
variables:
    db_password: 'auto:password:64'

Permissions issues

If you mount volumes from the server, the owner of the mounted directory in a container will be root (UID 0). This may cause issues because very often main process run from a different user. To avoid potential problems make sure you're either fixing volumes permissions in your container entrypoint script (recommended) or run the main process as root.

Did this answer your question?