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.
This PR creates a docker image using a Java 21 JRE automatically on commits to
main
.Specifically, it contains the following changes:
This script builds a docker image that allows running the bot.
The docker image can be executed like that (where
USERNAME/REPONAME
is the repository of the docker image, e.g.dan1st/javabot-test
)This command forwards both the HTTP and AJP port.
Publishing the image to Docker Hub requires the following secrets to be present:
DOCKERHUB_USERNAME
: The username (or organization name) for Docker Hub, e.g.dan1st
DOCKERHUB_REPONAME
: The repository name for Docker Hub, e.g.javabot
DOCKERHUB_TOKEN
The Docker Hub token for uploadingIf
DOCKERHUB_USERNAME
is missing, the image will not be uploaded but the build should still work.For testing, a repository is available here.
An example run can be found here
Alternatives
It would be possible to use one script for both verifying the build and uploading the Docker image and only build the image on the main branch. This way, there wouldn't be 2 similar scripts running on every push toThis was implemented.main
.native-image
for a Docker image not requiring a JRE. This was not done due to it being pretty fragile in my experience/quite some work to maintain (I don't want to write more bugreports to Spring/etc. due to issues with that).jlink
to create the JRE.server.address=127.0.0.1
toserver.address=0.0.0.0
in theapplication.properties
. See the merge notes.Merge notes - check before merging/deploying/using
The branchThis seems to be the case already.main
should be protected! Only PRs should be allowed. Make sure this is the case.For example, it would be possible to execute
docker pull USERNAME/REPONAME
and the aforementioneddocker run
command in order to (re)start the botThis could be done every time the bot is stopped with
/redeploy
.db
in the directory where thedocker run
command is executed.systems.json
config.application.properties
with the contentserver.address=0.0.0.0
to theconfig
directory. Something similar may be necessary for AJP though it seems to be accessible from outside anyways. If AJP is used without requiring the HTTP endpoint, this is not necessary.