Open
Description
Here's my exact use case, I want to write the Scala version of this shell script:
docker build -t graalvm-native-image - <<DOCKERFILE
FROM oracle/graalvm-ce:19.0.0
WORKDIR /opt/graalvm
RUN gu install native-image
ENTRYPOINT [native-image]
DOCKERFILE
Naively I thought this might work:
val dockerfile = """FROM oracle/graalvm-ce:19.0.0
WORKDIR /opt/graalvm
RUN gu install native-image
ENTRYPOINT [native-image]
"""
("docker build -t graalvm-native-image:19.0.0 -" #< dockerfile).!
But of course it doesn't work because String
is executed as a command, not used as the source of input, so the error you get is Cannot run program "FROM"
. This works:
("docker build -t graalvm-native-image:19.0.0 -" #<
new java.io.ByteArrayInputStream(dockerfile.getBytes("utf-8"))).!
But is not very nice from a DSL perspective. There should be a straight forward way to pass a String as the input of a command. Here are some examples of potential APIs that could work:
(Process.echo(dockerfile) #> "docker build -t graalvm-native-image:19.0.0 -").!
("docker build -t graalvm-native-image:19.0.0 -" #<<< dockerfile).!
Similar APIs could be supplied for byte arrays.