#Multi-stage build copy over single executable file with random name

1 messages · Page 1 of 1 (latest)

rustic pelican
#

Hello,
I am currently working on converting a Quarkus native image build into a GraalVM image using Dagger. The process involves building the native executable first and subsequently copying it over to a runtime image.
When executing ./mvnw package -Dnative, an executable file is generated with a name similar to app-SNAPSHOT-1.0.0-runner. However, the exact name of this file can vary.
How could I copy this executable with an unknown name over to the runtime image? In the Docker file for GraalVM, this issue is addressed with the command COPY target/*-runner /work/application.
Is there a comparable solution in Dagger? I noticed that with directory, I can set a filter, but this option doesn't seem to be available with file.

Thank you very much

trim burrow
#

that will put any .jar file under /target in the second container

rustic pelican
#

@trim burrow Thank you very much for your answer
I had this already but it is not the same as the docker command
COPY target/*-runner /work/application

This copies a file which ends in -runner and renames the file to application.
In my case the executable created by mvnw is generic (includes version and release) but it only exists one file with the ending of -runner.

Basically it would be comparable if the Container().File() would support wildcards like this
WithFile("/work/application", m.Ctr.File("/work/target/*-runner")).

trim burrow
#

in any case, you can do something like this in Dagger:

    srcDir := build.Directory("target")
    files, err := srcDir.Glob(ctx, []string{"*-runner"})
    if err != nil {
        return err
    }

    if len(files) == 1 {
        dag.Container().Directory("/work/target").WithFile("application", srDir.File(files[0]))
    }