Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Alternative config schema #131

Open
saitho opened this issue Mar 8, 2021 · 0 comments
Open

Alternative config schema #131

saitho opened this issue Mar 8, 2021 · 0 comments
Labels
incomplete more information is needed to work on this question Further information is requested
Milestone

Comments

@saitho
Copy link
Member

saitho commented Mar 8, 2021

While YAML files are easy to process, an alternative config schema may be easier to maintain.

The suggested schema is a block-based config schema. The idea of configuration blocks is easier to grasp, as the documentation would describe the structure of each block and where they can be used.

Similar schemas:

Domain declaration

Usecase:
I want to serve the application running inside the service "myservice" on port 8080 on the domain "mydomain.com" on port 80. It should require Basic Authentication with username "user" and password "pass".
The application has a WebSocket endpoint on path /socket.

Old

Taken from documentation

domains:
  - domain: mydomain.com
    expose:
      - internal_port: 8080
        external_port: 80
        service: myservice
        proxy_websocket_locations: ["/socket"]
    security:
        authentication:
            - type: basic
              username: user
              password: pass

New

The security block may be defined globally, inside a domain block or inside a port definition.

domain mydomain.com {
    serve {
        :80 {
            service = myservice
            port = 8080
            proxy_websocket_location {
                path = /socket
            }
            security {
                authentication {
                    type = basic
                    username = user
                    password = pass
                }
            }
        }
    }
    security {
        # ... same as security block inside port definition
    }
}

security {
    # ... same as security block inside port definition
}

Service declaration

Old

Taken from documentation

container:
  services:
    - name: app # service name
      image: nginxdemos/hello:latest # Docker image name
      volumes:
        - type: global # mount the "config" folder inside container at "/var/config". As both services use "global" they will mount the same source and share data.
          src: config
          dest: /var/config
        - type: local # mount the "data" folder inside container at "/var/data". This folder is not shared with other services ("local").
          src: data
          dest: /var/data
        - type: custom # mount the "/docker/data/test" folder inside container at "/var/test".
          src: /docker/data/test
          dest: /var/test
      hooks:
        execute_after_setup: ./setup.sh # this file is executed inside container after the container is created
        execute_before_destroy: ./destroy.sh # this file is executed inside container before the container is destroyed
    - name: db # service name
      image: mariadb:10.5 # Docker image name
      environment: # environment variables for Docker container
        MYSQL_ROOT_PASSWORD: example
      volumes_from: app:ro # mount all volumes from app service as readonly

New

service app {
  image = nginxdemos/hello:latest
  volume {
    type = global # mount the "config" folder inside container at "/var/config". As both services use "global" they will mount the same source and share data.
   src = config
   dest = /var/config
  }
  volume {
    type = local # mount the "data" folder inside container at "/var/data". This folder is not shared with other services ("local").
    src = data
    dest = /var/data
  }
  volume {
    type = custom # mount the "/docker/data/test" folder inside container at "/var/test".
    src = /docker/data/test
    dest = /var/test
  }
  hook after_setup {
    exec = ./setup.sh
  }
  hook before_destroy {
    exec = ./destroy.sh
  }
}
service db {
  image = mariadb:10.5
  volumes_from = app:ro
  environment {
    MYSQL_ROOT_PASSWORD = example
  }
}

Registry declaration

Old

Taken from documentation

container:
  registries:
    # Authenticate with Docker Hub for private images
    - username: mydockerhubuser
      password: mydockerhubpassword
    # Authenticate with custom Docker registry
    - username: myuser
      password: mypassword
      url: https://myregistry.com

New

registry {
  username = mydockerhubuser
  password = mydockerhubpassword
}
registry {
  username = myuser
  password = mypassword
  url = https://myregistry.com
}
@saitho saitho added the question Further information is requested label Mar 8, 2021
@saitho saitho changed the title Alternate config schema Alternative config schema Mar 8, 2021
@saitho saitho added this to the v2.0.0 milestone Apr 21, 2021
@saitho saitho mentioned this issue Apr 21, 2021
@saitho saitho modified the milestones: v2.0.0, v2.x Aug 21, 2021
@saitho saitho added the incomplete more information is needed to work on this label Aug 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
incomplete more information is needed to work on this question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant