0

I have a standard JCommander parameter which works fine when running the jar locally or through IntelliJ, but as soon as I try and load it through a dockerfile it returns:

Exception in thread "main" com.beust.jcommander.ParameterException: Was passed main parameter '-profile ${PROFILE}' but no main parameter was defined in your arg class

The code I'm loading the args through:

@Data
public static class Args {

    @Parameter(
            names = {"-profile", "-p"},
            arity = 1,
            required = true)
    private String profile;
}

I'm parsing that via:

 JCommander.newBuilder().addObject(ARGS).build().parse(args);

The entry point command I have in my Dockerfile:

ENTRYPOINT ["java" , "-jar", "/usr/app/app.jar", "-profile ${PROFILE}"]

Finally I'm just starting the container the usual way with ...-e PROFILE=dev

Is there something obvious I've missed here, do I just need to escape quotes somewhere or something?

Chris
  • 3,437
  • 6
  • 40
  • 73

1 Answers1

0

This was an obvious mistake which took longer than I care to admit to spot. The correct way to pass arguments if of course

ENTRYPOINT ["java" , "-jar", "/usr/app/app.jar", "-profile", "${PROFILE}"]

Note the comma between the key -profile and its value ${PROFILE}.

Chris
  • 3,437
  • 6
  • 40
  • 73