GeoSales-Evolution / self-deployable-docker

Docker repo capable of deploying itself... or something like that
MIT License
2 stars 2 forks source link

Allow for more fluid container description #33

Open jeffque opened 1 year ago

jeffque commented 1 year ago

It can be overwhelming for one used to the docker cli to learn a new API just to run docker commands.

For those who prefer an CLI like interface, there are equivalent ways to describe the same container. For example, those should be equaly defined:

docker_socket = "/var/run/docker.sock"

ouroborus_container = Container.new name: 'ouroborus', image: 'ouroborus', tag: 'latest'

ouroborus_container.restart :UNLESS_STOPPED
ouroborus_container.port 80,80
ouroborus_container.volume docker_socket,docker_socket

ouroborus_container_cli_described = Container.new name: 'ouroborus', image: 'ouroborus', tag: 'latest'

ouroborus_container_cli_described << "--restart" << "unless-stopped"
   << "-p" << "80:80" << "-v" << "#{docker_socket}:#{docker_socket}"

ouroborus_container_cli_described_array = Container.new name: 'ouroborus', image: 'ouroborus', tag: 'latest'

ouroborus_container_cli_described_array << [
  "--restart", "unless-stopped",
  "-p", "80:80",
  "-v", "#{docker_socket}:#{docker_socket}"
]

States

Adding those flags means that there will be many possible states possible. Like, if one wish to inform a public port, then

container << "-p"

ou

container << "--publish"

the next << argument must be a port or port pair. It will go from an state of "ready" to an state "waiting-port". Similar to volume, restart and other options.

The array shift, on the other hand, must end with a ready state. Like, this should be invalid:

container << [ "--publish", "443:33", "-v" ]

but this should be valid:

container << "--publish" << "443:33" << "-v"

A shift operation must always call a proper method from Ouroborus::Container.

Running in a non-ready state

If the container isn't in a ready state, asking for it to be run must be invalid.

Unkown cli flags

When using docker cli (see #32 ), there are cli flags that were not previously described. So, one should not be unable to call it (check #23 ). Thus, it is necessary to add an alternative for a user to inform those options. Must create a new issue to deal with this.