How to use it with modules that have replace directives
This looks interesting, but I wonder how to use it with our modules as we do not only have private repositories but also a fair amount of replacements for packages that are not (yet) updated upstream. Those can not use go install but need to be copied from other sources like a (release) URL or being built normally on the server. As we are using mage most of the time, I would like to have something like 'cloning/updating' the module and then running some command (which could be mage install or go build -o ...
Actually, this is not possible but seems reasonable. I'll try to add this possibility in the next updates of God.
What do you think about adding two new options in the conf file like the following?
clone_repo: github.com/pioz/go_hello_world_server # mandatory
clone_repo_destination_directory: /home/pioz # default home
build_cmd: go build -o hello # default go build -o service_name
If the option clone_repo is present, God tries to install the service without using go install but by following these steps:
- clone the repo
clone_repoinclone_repo_destination_directory - run
build_cmdin theclone_repo_destination_directory - copy the just compiled binary in
go_bin_directory
This sounds good to me. The cloning process may have to check if updating works and falling back to force an overwrite. It would also be good to have the possibility to give a branch or tag that should be used.
By the way, cloning and having a build command also makes this whole system much more usable as this will work with much more than Go modules. Also, running docker images comes to mind.
@oderwat and what do you think instead to clone and compile the program on the remote server, just compiling the binary in the local machine and copying only the compiled executable on the server?
For our use cases, I guess the compile from a cloned repository would be most useful. If you have a compiled binary it would be nice to be able to use that too. You could even use one (staging) machine to compile it and the build script also does some CI checks and after this works the other machines could get the binary from there.