I am having an issue with finding or creating a docker image that I can use on GitLab CI that will allow me to run mvn package
, that in turn calls spring-boot:build-image
I have specified in my config that I need the dind
container as a service, but I am unsure the best way to find a docker container that has docker, java and maven installed.
I am also not sure exactly how to create my own that I can then share for this purpose.
I am using dev containers for this project so I might try to snapshot that but that doesn’t seem the best for repeatability.
2
Answers
Using the docker image
docker:24.0.7
I was able to add java 21 to it as part of thebefore_script
to allow me to run both the docker commands and the java/maven (using the wrapper) ones.The Docker image is built on Alpine so you can use
before_script: - apk add --update openjdk21
You will need to pass the parameters to the pom file as variables for it to authenticate with GitLab for the push, logging on via the docker cli did not work.
.gitlab-ci.yaml
Why not wrap maven in your project? If you then use a docker image with a jdk you can build and run it easily.
Please be aware that running with jdk is not best practice for production code.