Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java8/gradle support for proxy settings #106

Closed
wants to merge 2 commits into from

Conversation

padiazg
Copy link
Contributor

@padiazg padiazg commented Dec 20, 2018

Modified Dockerfile for java8 to accept gradle_ops via --build_arg
With this modification now you can pass graddle_ops using --build_arg, so you can specify proxy settings for Gradle.
Signed-off-by: Patricio Diaz [email protected]

Description

  • Moved org.gradle.daemon=false to gradle.propoerties, deleted it from Dockerfile
  • Added ARG and ENV command to Dockerfile to catch GRADLE_OPTS passed as parameter.
  • Updated README.md to show how to use it in an corporate proxy scenario

Motivation and Context

This is needed for successfully building functions if you are behind a proxy
#105

  • I have raised an issue to propose this change (required)

Which issue(s) this PR fixes

Fixes #105

How Has This Been Tested?

  1. Created new project folder
  2. Copied manually modified template folder into it.
  3. faas-cli.exe new java8-proxy --lang java
  4. faas-cli up -f java8-proxy.yml -b gradle_opts="-Dhttp.proxyHost=my-proxy -Dhttp.proxyPort=3128 -Dhttps.proxyHost=my-proxy -Dhttps.proxyPort=3128"

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.

…oved org.gradle.daemon to gradle.propoerties. Updated readme.md

Signed-off-by: Patricio Diaz <[email protected]>
@tessellator
Copy link
Contributor

I think this looks great! However, I am concerned about always having to specify any additional gradle opts on the command line. Personally, I would like to have the ability to persist and version control the options in addition to providing them on the command line. Persisting the options would reduce tribal knowledge and/or additional scripts required to build functions.

This could be achieved by moving the gradle.properties file into the function folder and adding a command to the Dockerfile to move it into the root project folder before building, e.g.:

...
COPY . /home/app/
RUN if [ -f /home/app/function/gradle.properties ] ; then mv /home/app/function/gradle.properties /home/app/gradle.properties ; fi
RUN gradle build
...

If you want to ensure that org.gradle.daemon=false is always specified, you could instead append a function-local gradle.properties file to the gradle.properties file in the root build folder.

This approach would continue to work with the --build-arg change you have already made. What do you think?

@padiazg
Copy link
Contributor Author

padiazg commented Mar 6, 2019

I like your suggestion, as I'm not an experienced Java programmer. I'll try it and see to add it to the PR.

Can you explain this a little more to me, please:

If you want to ensure that org.gradle.daemon=false is always specified, you could instead append a function-local gradle.properties file to the gradle.properties file in the root build folder.

@tessellator
Copy link
Contributor

Absolutely! I apologize for not being clear in my previous comment. All I mean is that you could replace:

RUN if [ -f /home/app/function/gradle.properties ] ; then mv /home/app/function/gradle.properties /home/app/gradle.properties ; fi

with

RUN if [ -f /home/app/function/gradle.properties ] ; then cat /home/app/function/gradle.properties >> /home/app/gradle.properties ; fi

in my previous example. This would ensure that the gradle.properties file you created in this PR would always be used (org.gradle.daemon=false), and that anything a dev added in a gradle.properties file with their function (like proxy settings) would be appended to it.

@alexellis
Copy link
Member

Sorry this PR has become inactive, I'm going to close. Feel free to raise a new one if required to cover java11, java11-vert-x and so forth. cc @pmlopes

@alexellis alexellis closed this Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proxy settings for java8 template
3 participants