Standard project structure#21
Conversation
Change structure to make it closer to the standard Go module structure. Change module definition file to reflect repo location. Retool Dockerfile to build from this new structure To compile the minimum Go version had to be bumped from 1.18 to 1.21, as github.com/prometheus/client_golang (as downloaded by the original Dockerfile) required it to build.
|
Hey, i appreciate your work. |
|
I thought this project might be useful, so I figured I'd contribute back.
The short answer is that it enables reproducible builds, by ensuring that everyone uses the exact same versions of all dependencies. With it committed, you get the same deps (or at least you have the means to verify it) inside and outside Docker as well. Check here for some official rationale about committing the |
|
I will try to merge this tommorrow when i can check this in my dev system. I tried to abstract the go.sum so you can just rebuild the image and all the newest components get pulled directly. |
|
Do you mean the build process should get the "latest" versions automatically? There are So, I don't think there is a simple command that will do this automatically as the Go developers seem to favor reproducibility and stability over simplistic upgrades. (These are good reasons too, in my view, given the tasks that Go was made to solve) As an example, you should be able to list available upgrades with: go list -m -u allMy suggestion is to use a GitHub action to "vet" the dependencies using the go tools and some scripting, and maybe automatically add a GitHub issue if there is a big enough version bump in a dependency. It would not surprise me if someone somewhere have already made a tool for this and open-sourced it. As with almost anything else... |
This PR introduces a more standardized Go module structure, making it easier to build and work with. I realize it might be a bit "disruptive", but I think it's a good idea.
app/folder is moved out to the project root.github.com/prometheus/client_golang(at least when downloaded in the originalDockerfileseemed to require it.Dockerfileis retooled to build with this new structure.There is also a small change to the message loop in
main(), I guess caused by a breaking change in the later version ofgovici.Using the new structure it is now trivial to build both "natively" or in Docker.
Natively:
go mod downloadgo build -o ipsec-exporter .Docker:
docker build [...]Cross-compilations are just as simple, should it be required.