Coder Social home page Coder Social logo

Comments (14)

meltsufin avatar meltsufin commented on June 15, 2024 1

My mistake, sorry. You found the right openjdk image.

from openjdk-runtime.

meltsufin avatar meltsufin commented on June 15, 2024

JAVA_OPTS is set in setup-env.bash, which is only invoked in the docker-entrypoint.bash if the run command starts with java or some other argument that is not an executable. What does your docker run command look like?

from openjdk-runtime.

tanin47 avatar tanin47 commented on June 15, 2024

For playframework, we run the bash script generated by sbt dist. The script eventually runs java with a lot of arguments, and, fortunately, the script uses the JAVA_OPTS env.

Here's the script template: https://github.com/sbt/sbt-native-packager/blob/master/src/main/resources/com/typesafe/sbt/packager/archetypes/scripts/bash-template#L297

Here's my docker run command:

CMD ["bin/myappname", "-Dlogger.file=conf/prod.xml", "-Dconfig.file=conf/prod.conf",  "-Dplay.crypto.secret=fakesecret", "-Dhttp.port=8080"]

I make my own docker-entrypoint.bash, and this is how it looks like:

#!/bin/bash
source /setup-env.bash \
  && exec env JAVA_OPTS="$JAVA_OPTS" "$@" 2>&1

from openjdk-runtime.

meltsufin avatar meltsufin commented on June 15, 2024

If there is a way to start the app directly via the java executable, then you wouldn't need the custom CMD or the modified docker-entrypoint.bash. I would recommend looking into that option.

I'm not sure about modifying the actual runtime image the way you suggested to accommodate the Scala Playframework usecase. If the usecase was more generic, it would make more sense, but otherwise, extending the runtime image with a custom Dockerfile seems to be the most appropriate solution.

from openjdk-runtime.

meltsufin avatar meltsufin commented on June 15, 2024

@tanin47 On a second thought, if we simply added export JAVA_OPTS line before the exec "$@" in docker-entrypoint.bash, would it solve your issue?

from openjdk-runtime.

tanin47 avatar tanin47 commented on June 15, 2024

If there is a way to start the app directly via the java executable, then you wouldn't need the custom CMD or the modified docker-entrypoint.bash. I would recommend looking into that option.
@tanin47 On a second thought, if we simply added export JAVA_OPTS line before the exec "$@" in docker-entrypoint.bash, would it solve your issue?

This would be helpful. I'll be able to get rid of my docker-entrypoint.bash completely. (One fewer file to maintain)

But I need to verify first whether export works as expected. There is some weird issue with export inside a bash script. I'll try and report back.

Thank you!

from openjdk-runtime.

gregw avatar gregw commented on June 15, 2024

@tanin47 The docker-entrypoint has been written as it is so that follows the docker standard practises that easily allow other args and/or commands to be run in the image. I think that it is worth the effort to use the standard docker-entrypoint, potentially with modifications to fit your requirements.

from openjdk-runtime.

tanin47 avatar tanin47 commented on June 15, 2024

I confirm that adding export JAVA_OPTS="$JAVA_OPTS" in docker-entrypoint.bash works as well.

I also notice that setup-env.bash is only invoked if the first argument is neither executable or java . Our first argument is executable. This would need to be fixed.

Is there a downside for running setup-env.bash and setting $JAVA_OPTS every time? The users (who use this JDK image) would expect JAVA_OPTS to be set properly regardless how their commands look like.

from openjdk-runtime.

gregw avatar gregw commented on June 15, 2024

I don't see any problem running setup-env.bash all of the time. I also think the script should export all the variables it sets. I'll prepare a PR...

from openjdk-runtime.

tanin47 avatar tanin47 commented on June 15, 2024

Thank you! This change is super helpful. Please let me know when the image is deployed. I'll test it promptly.

from openjdk-runtime.

tanin47 avatar tanin47 commented on June 15, 2024

Is this deployed yet?

from openjdk-runtime.

meltsufin avatar meltsufin commented on June 15, 2024

Yes, and it will be made :latest soon.
For now, try using this image: gcr.io/google-appengine/jetty:9.4-2017-01-26_21_46

from openjdk-runtime.

tanin47 avatar tanin47 commented on June 15, 2024

Hmm.. I can't make the jetty image work. Do you have the openjdk version?

from openjdk-runtime.

tanin47 avatar tanin47 commented on June 15, 2024

I tested against gcr.io/google-appengine/openjdk:8-2017-01-26_21_19

It seems to work. I only need CMD command and can remove my own docker-entrypoint.bash. Thank you for making this change.

from openjdk-runtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.