Right now I have an program, written in golang, that I am trying to run within a minimal container. When launched, this go program happens to start up another sub-program written in java, which also needs to run in the container. I am wondering how to construct my Dockerfile to accomplish this as a "distroless" image.
Right now I am exploring a solution like so:
FROM <golang-distro> as go-builder
FROM <java-distro> as java-builder
FROM <minimal-base-image>
# copy over all files needed to set up golang runtime to run go-parent-service
COPY --from=go-builder /<golang-binaries> /
# copy over all files needed to set up java runtime so go-parent-service can run its java sub process
COPY --from-java-builder /<jvm-binaries> /
# executable for the golang service
COPY /go-parent-service /
# run the golang service, which will also start up the java service as sub process
CMD ["/go-parent-service"]
Does this approach make sense, or is there a better way to construct this image? I am aware the go service starting up the java service makes things a bit trickier, and may not be best practice. However since I do not own this executable I am unable to separate out these services and run them in different containers.