Using Skaffold with Java
There is a discussion going on about adding support for Java apps here, you can very much use Docker multistage build with Skaffold. A probably working example is available here
Your build portion of Skaffold file will look something like:
apiVersion: skaffold/v1alpha2kind: Configbuild: tagPolicy: dateTime: format: 2006-01-02_15-04-05.999_MST timezone: Local artifacts: - imageName: <repo>/<image> workspace: ./appdir
In the appdir
- you can use a multistage Dockerfile and integrate with rest of the workflow. Multistage Dockefile will build artefact in one stage and create a container using the artefact of the first stage.
Skaffold now supports JIB out of the box which will be more efficient than multistage Dockerfile building! Check out the JIB Maven example in Skaffold.
I haven't tried it yet, but alternatively now it allows you to specify a custom build script: Custom Build Script
I'm assuming you could try as below, or source a build.sh
as their documentation exemplifies.
build: artifacts: - image: my-image custom: buildCommand: mvn package && docker build .