通过代理使用 mvn 和 jib 构建 docker 图像
Build docker image using mvn and jib through a proxy
我正在 运行 使用此命令使用 maven
和 jib
构建 docker
图像
mvn compile jib:dockerBuild -Djib.to.image="$IMAGE_NAME"
这个命令在我的机器上工作得很好,因为它会从互联网上下载一些东西,但是,当我尝试 运行 它在管道(在 AWS 上)中时,情况并非如此 运行 在需要代理的企业网络中
我已经尝试过这个命令:
export MAVEN_OPTS="-DsocksProxyHost=<host> -DsocksProxyPort=<port>"
但它没有用,而且我不想触摸 settings.xml
文件,因为我无权访问它,所以我想要的唯一解决方案是提供一个带有所列命令的代理以上。
这是命令的整个日志:
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/kr/motd/maven/os-maven-plugin/1.6.2/os-maven-plugin-1.6.2.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin kr.motd.maven:os-maven-plugin:1.6.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for kr.motd.maven:os-maven-plugin:jar:1.6.2 @
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.bla:backend:1.0-SNAPSHOT (/codebuild/output/src794035415/src/backend/pom.xml) has 1 error
[ERROR] Unresolveable build extension: Plugin kr.motd.maven:os-maven-plugin:1.6.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for kr.motd.maven:os-maven-plugin:jar:1.6.2: Could not transfer artifact kr.motd.maven:os-maven-plugin:pom:1.6.2 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/kr/motd/maven/os-maven-plugin/1.6.2/os-maven-plugin-1.6.2.pom: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException
[Container] 2021/02/26 11:15:48 Command did not exit successfully cd backend && mvn compile jib:dockerBuild -Dhttp.proxyHost=http://path/to/proxy -Dhttp.proxyPort=8080 -Djib.to.image="$JAVA_SERVICE_IMAGE_NAME" && cd .. exit status 1
[Container] 2021/02/26 11:15:48 Phase complete: BUILD State: FAILED_WITH_ABORT
[Container] 2021/02/26 11:15:48 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: cd backend && mvn compile jib:dockerBuild -Dhttp.proxyHost=http://path/to/proxy -Dhttp.proxyPort=8080 -Djib.to.image="$JAVA_SERVICE_IMAGE_NAME" && cd ... Reason: exit status 1
有多种方法。首先,查看此 Oracle doc 以了解您可以设置的标准 Java 网络属性。
在 settings.xml
(Maven 设置文件)中设置代理配置。例如,
<proxies>
<proxy>
<id>for-https-proxying</id> <!-- Make sure you use different IDs -->
<!-- For HTTPS proxying. AFAIK, the Maven doc is wrong about this. -->
<protocol>https</protocol>
<host>my.company.proxy.com</host>
<nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts>
</proxy>
<proxy>
<id>for-http-proxying</id>
<protocol>http</protocol> <!-- for HTTP proxying -->
<host>my.company.proxy.com</host>
<nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts>
</proxy>
</proxies>
查看 Maven Settings Reference 了解更多详情。
在 运行 Jib (JVM) 时设置网络系统属性。例如,一个命令行,
$ mvn -Dhttp.proxyHost=my.company.proxy.com \
-Dhttp.proxyPort=... \
-Dhttp.nonProxyHosts=... \
-Dhttps.proxyHost=... \
-Dhttps.proxyPort=... \
compile jib:build
我正在 运行 使用此命令使用 maven
和 jib
构建 docker
图像
mvn compile jib:dockerBuild -Djib.to.image="$IMAGE_NAME"
这个命令在我的机器上工作得很好,因为它会从互联网上下载一些东西,但是,当我尝试 运行 它在管道(在 AWS 上)中时,情况并非如此 运行 在需要代理的企业网络中
我已经尝试过这个命令:
export MAVEN_OPTS="-DsocksProxyHost=<host> -DsocksProxyPort=<port>"
但它没有用,而且我不想触摸 settings.xml
文件,因为我无权访问它,所以我想要的唯一解决方案是提供一个带有所列命令的代理以上。
这是命令的整个日志:
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/kr/motd/maven/os-maven-plugin/1.6.2/os-maven-plugin-1.6.2.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin kr.motd.maven:os-maven-plugin:1.6.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for kr.motd.maven:os-maven-plugin:jar:1.6.2 @
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.bla:backend:1.0-SNAPSHOT (/codebuild/output/src794035415/src/backend/pom.xml) has 1 error
[ERROR] Unresolveable build extension: Plugin kr.motd.maven:os-maven-plugin:1.6.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for kr.motd.maven:os-maven-plugin:jar:1.6.2: Could not transfer artifact kr.motd.maven:os-maven-plugin:pom:1.6.2 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/kr/motd/maven/os-maven-plugin/1.6.2/os-maven-plugin-1.6.2.pom: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException
[Container] 2021/02/26 11:15:48 Command did not exit successfully cd backend && mvn compile jib:dockerBuild -Dhttp.proxyHost=http://path/to/proxy -Dhttp.proxyPort=8080 -Djib.to.image="$JAVA_SERVICE_IMAGE_NAME" && cd .. exit status 1
[Container] 2021/02/26 11:15:48 Phase complete: BUILD State: FAILED_WITH_ABORT
[Container] 2021/02/26 11:15:48 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: cd backend && mvn compile jib:dockerBuild -Dhttp.proxyHost=http://path/to/proxy -Dhttp.proxyPort=8080 -Djib.to.image="$JAVA_SERVICE_IMAGE_NAME" && cd ... Reason: exit status 1
有多种方法。首先,查看此 Oracle doc 以了解您可以设置的标准 Java 网络属性。
在
settings.xml
(Maven 设置文件)中设置代理配置。例如,<proxies> <proxy> <id>for-https-proxying</id> <!-- Make sure you use different IDs --> <!-- For HTTPS proxying. AFAIK, the Maven doc is wrong about this. --> <protocol>https</protocol> <host>my.company.proxy.com</host> <nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts> </proxy> <proxy> <id>for-http-proxying</id> <protocol>http</protocol> <!-- for HTTP proxying --> <host>my.company.proxy.com</host> <nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts> </proxy> </proxies>
查看 Maven Settings Reference 了解更多详情。
在 运行 Jib (JVM) 时设置网络系统属性。例如,一个命令行,
$ mvn -Dhttp.proxyHost=my.company.proxy.com \ -Dhttp.proxyPort=... \ -Dhttp.nonProxyHosts=... \ -Dhttps.proxyHost=... \ -Dhttps.proxyPort=... \ compile jib:build