I am running a scala script with ammonite. I need to pass JAVA_OPTS to limit the memory consumed by ammonite. According to the ammonite docs, I can do it by doingJAVA_OPTS='-Xmx<limit>' amm <scala script>
Now I want to run this script inside a docker container, which I am doing with like this:
FROM <open jdk image>
WORKDIR /opt/docker
ADD scm-source.json /
ADD --chown=daemon:daemon deps/amm /opt/docker
RUN mkdir amm_home && chown daemon:daemon amm_home
RUN mkdir data && chown daemon:daemon data
ADD --chown=daemon:daemon UserPrefExporter.sc /opt/docker
USER daemon
ENTRYPOINT ["./amm", "-h", "amm_home", "UserPrefExporter.sc"]
This runs fine and runs the script. The problem lies in passing the JAVA_OPTS to amm.
ENTRYPOINT requires first parameter to be the executable but I want to have JAVA_OPTS before amm.
How to achieve this?
You can declare environment variables with ENV
:
...
ADD --chown=daemon:daemon UserPrefExporter.sc /opt/docker
USER daemon
ENV JAVA_OPTS="-Xmx<limit>"
ENTRYPOINT ["./amm", "-h", "amm_home", "UserPrefExporter.sc"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With