Description
Gradle needs proxy options to be specified explicitly, ignores http_proxy, https_proxy and no_proxy environment variables.
Expected Behaviour
Grable run the build successfully
Step 9/24 : RUN gradle build
---> Running in 0f347861cbc9
Welcome to Gradle 4.8.1!
...
Download https://jcenter.bintray.com/com/google/guava/guava/23.0/guava-23.0.pom
...
> Task :model:compileJava
Download ...
...
> Task :function:compileJava
> Task :entrypoint:compileJava
> Task :entrypoint:processResources NO-SOURCE
> Task :entrypoint:classes
> Task :entrypoint:jar
> Task :entrypoint:startScripts
> Task :function:processResources NO-SOURCE
> Task :function:classes
> Task :function:jar
> Task :model:processResources NO-SOURCE
> Task :model:classes
> Task :model:jar
> Task :entrypoint:distTar
> Task :entrypoint:distZip
> Task :entrypoint:assemble
Download ...
> Task :entrypoint:compileTestJava
> Task :entrypoint:processTestResources NO-SOURCE
> Task :entrypoint:testClasses
> Task :entrypoint:test NO-SOURCE
> Task :entrypoint:check UP-TO-DATE
> Task :entrypoint:build
> Task :function:assemble
> Task :function:compileTestJava
> Task :function:processTestResources NO-SOURCE
> Task :function:testClasses
> Task :function:test
> Task :function:check
> Task :function:build
> Task :model:assemble
> Task :model:compileTestJava
> Task :model:processTestResources NO-SOURCE
> Task :model:testClasses
> Task :model:test
> Task :model:check
> Task :model:build
BUILD SUCCESSFUL in 50s
14 actionable tasks: 14 executed
Current Behaviour
Gradle fails when trying to download modules
Step 9/24 : RUN gradle build
---> Running in 3cb02b281333
Welcome to Gradle 4.8.1!
...
> Task :model:compileJava
> Task :model:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':model:compileClasspath'.
> Could not resolve org.apache.commons:commons-math3:3.6.1.
Required by:
project :model
> Could not resolve org.apache.commons:commons-math3:3.6.1.
> Could not get resource 'https://jcenter.bintray.com/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.pom'.
> Could not GET 'https://jcenter.bintray.com/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection refused (Connection refused)
> Could not resolve org.apache.commons:commons-math3:3.6.1.
> Could not get resource 'https://jcenter.bintray.com/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.pom'.
> Could not GET 'https://jcenter.bintray.com/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection refused (Connection refused)
> Could not resolve com.google.guava:guava:23.0.
Required by:
project :model
> Could not resolve com.google.guava:guava:23.0.
> Could not get resource 'https://jcenter.bintray.com/com/google/guava/guava/23.0/guava-23.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/google/guava/guava/23.0/guava-23.0.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection refused (Connection refused)
> Could not resolve com.google.guava:guava:23.0.
> Could not get resource 'https://jcenter.bintray.com/com/google/guava/guava/23.0/guava-23.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/google/guava/guava/23.0/guava-23.0.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection refused (Connection refused)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 47s
1 actionable task: 1 executed
The command '/bin/sh -c gradle build' returned a non-zero code: 1
2018/12/20 11:13:54 ERROR - Could not execute command: [docker build --build-arg http_proxy=http://10.118.1.80:3128/ --build-arg https_proxy=http://10.118.1.80:3128/ -t padiazg/crc-bcp:latest .]
Possible Solution
Two successful options:
a) Update GRADLE_OPTS in the Dockerfile like this
ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dhttp.proxyHost=10.118.1.80 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=10.118.1.80 -Dhttps.proxyPort=3128"
b) Create gradle.properties at the root if the java8 template with following content:
systemProp.http.proxyHost=10.118.1.80
systemProp.http.proxyPort=3128
systemProp.http.nonProxyHosts=localhost|127.0.0.1|10.22.*|10.118.*
systemProp.https.proxyHost=10.118.1.80
systemProp.https.proxyPort=3128
systemProp.https.nonProxyHosts=localhost|127.0.0.1|10.22.*|10.118.*
Steps to Reproduce (for bugs)
You must be behind a proxy, without direct access to the Internet.
$ faas-cli new test-function --lang java8
$ faas-cli build
Context
Both solutions proposed above works, but you have to modify the template after it is downloaded.
You need to do this for every project you are creating, of if for some reason you download the template again.
Also the template folder is specified in .gitignore, so this configuration wont be saved to your git repository.
Your Environment
- Docker version
docker version
(e.g. Docker 17.0.05 ):
Client: Docker Engine - Community
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:47:51 2018
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:55:00 2018
OS/Arch: linux/amd64
Experimental: false
-
Are you using Docker Swarm or Kubernetes (FaaS-netes)?
Docker Swarm and Kubernetes -
Operating System and version (e.g. Linux, Windows, MacOS):
Windows and Linux -
Link to your project or a code example to reproduce issue: