Consistency in run for build, deploy, et al. #515
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
purpose
Consistency between running containers for build and deploy and possibly other scenarios in the future.
problem
We need consistency between the
docker runforbuildanddocker runfordeploy, but in future other scenarios may also present itself. With the addition ofdokku-argswe can now mount volumes, for example, but this is currently only implemented for deploy which is problematic for the build process which is now unaware of these volumes.Another inconsistency which already revealed itself as well, as pointed out by #511, is the absence of a
CONTAINERlookup which is only created at deploy and never populated when a build fails or is terminated.proposal
To avoid duplication and improve reusability a function wrapping the common functionality can be employed, as this merge request would suggest. To reduce cognitive friction in implementation, a compatibility with the original docker implemented call signature was sought hence the function name
docker_run.The method will dynamically parse arguments to deduce that everything before the global variable
$IMAGEis considered call arguments and everything post this reference will be part and purpose of the command. This allows executing of the functiondocker_runin exactly the same familiar fashion as we would otherwise calldocker runfor this purpose with no concern fordokku-args, which gets injected before the image, or any future evolutions of the way a container is run.This was also the most logical instance at which to log the container id while effectively obfuscating the complexities/requirement from the caller which continues to receive the output as it normally would.
possibilities
Currently only applicable to and implemented for build and deploy but may in future apply to other scenarios as well.
Another consideration would be to enhance the hook api and to separate the arguments passable to build and deploy etc. which should not obstruct this merge request nor be reason to complicate the calling signature as is proposed.
Due to the fixed nature of the process flow identifying which process is calling can be facilitated by a simple counter persisted externally or based on other artifacts created in the
$APPlocation. We could choose to simply pass this identifier along to a newdokku-argshook specification or create separate hooks for each all without additional requirements to the caller.