Graylog2 / graylog-docker

Official Graylog Docker image
https://hub.docker.com/r/graylog/graylog/
Apache License 2.0
361 stars 133 forks source link

Fix Dockerhub build. #144

Closed malcyon closed 3 years ago

malcyon commented 3 years ago

Since the Dockerfile is now in a subdirectory, the hook directory needs to be moved.

Per the docs:

Create a folder called hooks in your source code repository at the same directory level as your Dockerfile.

https://docs.docker.com/docker-hub/builds/advanced/

I forked the github repo and the dockerhub repo to test this new setup and it does work.

I've also created new dockerhub repos for graylog-forwarder and graylog-enterprise. Splitting up the hook files like this will ensure that each dockerhub repo only builds the intended image.

The graylog and graylog-enterprise builds will be kicked off (as usual) via the 4.0.1-1 style tag. The graylog-forwarder image build will be kicked off with forwarder-4.0.1-1 style tags.

The regexes in the dockerhub build logic have been updated so that graylog and graylog-enterprise images don't build when we create a forwarder-X.X.X tag.

malcyon commented 3 years ago

The Dockerhub build rules for graylog were previously:

Source Type Source Docker Tag Dockerfile location Build Context
Tag /.*/ {sourceref} Dockerfile /
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2} Dockerfile /
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2}.{\3} Dockerfile /

For the graylog image, I have changed them to:

Source Type Source Docker Tag Dockerfile location Build Context
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+).*/ {sourceref} docker/oss/Dockerfile /
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2} docker/oss/Dockerfile /
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2}.{\3} docker/oss/Dockerfile /

For the graylog-enterprise image, I have changed them to:

Source Type Source Docker Tag Dockerfile location Build Context
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+).*/ {sourceref} docker/enterprise/Dockerfile /
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2} docker/enterprise/Dockerfile /
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2}.{\3} docker/enterprise/Dockerfile /

This will ensure that when we create a tag like 4.0.1-1, that we will get images tagged with:

It will also ensure that tags like forwarder-3.3.9 don't trigger builds for the other images.

The graylog-forwarder regexes are:

Source Type Source Docker Tag Dockerfile location Build Context
Tag /forwarder-.*/ {sourceref} docker/forwarder/Dockerfile /
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2} docker/forwarder/Dockerfile /
Tag /^([0-9]+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2}.{\3} docker/forwarder/Dockerfile /

This creates tags for graylog-forwarder like:

malcyon commented 3 years ago

For future reference, when dockerhub fails to match its regex for a tag, you can tell by checking the webhooks in the github repo. There will be a failed webhook with an http 500 error, saying:

{"error": "Our service is temporarily unavailable. We'll be back soon!"}

That is a clue that the regex is wrong.

You can also redeliver failed webhooks from github after fixing the regex.

malcyon commented 3 years ago

@bernd Alright, you rightly pointed out that this could be a problem when we do a new 3.3 release, because it would be looking for the Dockerfile in the wrong place. I propose this solution:

For the graylog image:

Source Type Source Docker Tag Dockerfile location Build Context
Tag /^([0-3]).([0-9]+).([0-9]+)-([0-9]+).*/ {sourceref} Dockerfile /
Tag /^([0-3]).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2} Dockerfile /
Tag /^([0-3]).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2}.{\3} Dockerfile /
Tag /^([4-9]|\d\{2,\}+).([0-9]+).([0-9]+)-([0-9]+).*/ {sourceref} docker/oss/Dockerfile /
Tag /^([4-9]|\d\{2,\}+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2} docker/oss/Dockerfile /
Tag /^([4-9]|\d\{2,\}+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2}.{\3} docker/oss/Dockerfile /

For the graylog-enterprise image:

Source Type Source Docker Tag Dockerfile location Build Context
Tag /^([4-9]|\d\{2,\}+).([0-9]+).([0-9]+)-([0-9]+).*/ {sourceref} docker/enterprise/Dockerfile /
Tag /^([4-9]|\d\{2,\}+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2} docker/enterprise/Dockerfile /
Tag /^([4-9]|\d\{2,\}+).([0-9]+).([0-9]+)-([0-9]+)$/ {\1}.{\2}.{\3} docker/enterprise/Dockerfile /

Some thoughts: