god icon indicating copy to clipboard operation
god copied to clipboard

How to use it with modules that have replace directives

Open oderwat opened this issue 3 years ago • 5 comments

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 ...

oderwat avatar May 28 '22 11:05 oderwat

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:

  1. clone the repo clone_repo in clone_repo_destination_directory
  2. run build_cmd in the clone_repo_destination_directory
  3. copy the just compiled binary in go_bin_directory

pioz avatar May 28 '22 12:05 pioz

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.

oderwat avatar May 28 '22 15:05 oderwat

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 avatar May 28 '22 15:05 oderwat

@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?

pioz avatar May 29 '22 11:05 pioz

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.

oderwat avatar May 29 '22 11:05 oderwat