Skip to content

Refactor docker.toml configuration into sections #20

@kofalt

Description

@kofalt

Right now, we express three fundamentally different concepts:

  • Image name, parent image name
  • Image settings (which you might want to extend in a child folder)
  • Run targets (default, build, etc)

The current format has the following problems:

  • The per-target setting inheritance is confusing and overly clever.
    • Worse, it conflates the default default run target with the default settings.
  • Settings are loaded in an unintuitive manner; right now, in Boxen, most images can omit the build target's command... unless they change the default target's command. What?
  • Placing the image's name in the default run target and the upstream/index image name in the build target is another strange facet.
  • Surprising behaviour possible: specify different images in different targets; hilarity ensues.

... The list goes on. Basically, not a bad first draft, but let's scrap it and move on.

Current format:

#Settings inheritance is a complete mess

# Why is "default" holding settings and commands?
[default]
    command = [ "/bin/echo", "Hello from docket!" ]
    dns = [ "8.8.8.8", "8.8.4.4" ]
    image = "docket.polydawn.net/ubuntu/12.04"

[bash]
    command = [ "/bin/bash" ]

[build]
    command = [ "/cwd/build.sh" ]
    # Why is the image name mentioned in a target?
    upstream = "index.docker.io/ubuntu/12.04" 
    index = "ubuntu:12.04"

Proposed new format: only settings inherit.

# Hey, this section makes intuitive sense!
[image]
    name     = "docket.polydawn.net/ubuntu/12.04"
    upstream = "index.docker.io/ubuntu/12.04"
    index    = "ubuntu:12.04"

# These apply to all targets, and all images in child folders.
[settings]
        dns = [ "8.8.8.8", "8.8.4.4" ]

# Target settings do not apply to any other file - only this target, for this image.
[target.run] # Renamed default target to run, see #30
    command = [ "/bin/echo", "Hello from docket!" ]
    ports = [ "80", "80" ]

[target.bash]
    command = [ "/bin/bash" ]

[target.build]
    command = [ "/cwd/build.sh" ]
    # This ports setting only applies to the build target!
    ports = [ "80", "8080" ]

Advantages: correct all the problems enumerated above, vastly simplified.
Disadvantages: lose some niche features like only specifying the bash target once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions