Skip to content

Commit b84d17f

Browse files
phoenikzEwelina Wilkosz
authored andcommitted
Decouple host JAVA_OPTS from container JAVA_OPTS (#205)
Adding JAVA_PROXY variable to provide to docker image build, so that when container is host for new image build, the JAVA_PROXY variable will be added to JAVA_OPTS instead of host's JAVA_OPTS, keeping control of the JAVA_OPTS in the Dockerfile
1 parent b9295db commit b84d17f

6 files changed

Lines changed: 9 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ git clone https://github.com/Praqma/JenkinsAsCodeReference.git
3131
export http_proxy=<empty or proxy address>
3232
export https_proxy=<empty or proxy address>
3333
export no_proxy=<empty or proxy address>
34-
export JAVA_OPTS=<empty or -Dhttps.proxyHost=<proxy address> -Dhttps.proxyPort=<proxy port> -Dhttp.nonProxyHosts=localhost,127.0.0.1,*.whatever.com -Dhttp.proxyHost=<proxy address> -Dhttp.proxyPort=<proxy port>
34+
export JAVA_PROXY=<empty or -Dhttps.proxyHost=<proxy address> -Dhttps.proxyPort=<proxy port> -Dhttp.nonProxyHosts=localhost,127.0.0.1,*.whatever.com -Dhttp.proxyHost=<proxy address> -Dhttp.proxyPort=<proxy port>
3535
```
3636

3737
or
@@ -41,7 +41,7 @@ cat > ~/.bashrc <<- EOM
4141
export http_proxy=<empty or proxy address>
4242
export https_proxy=<empty or proxy address>
4343
export no_proxy=<empty or proxy address>
44-
export JAVA_OPTS=<empty or -Dhttps.proxyHost=<proxy address> -Dhttps.proxyPort=<proxy port> -Dhttp.nonProxyHosts=localhost,127.0.0.1,*.whatever.com -Dhttp.proxyHost=<proxy address> -Dhttp.proxyPort=<proxy port>
44+
export JAVA_PROXY=<empty or -Dhttps.proxyHost=<proxy address> -Dhttps.proxyPort=<proxy port> -Dhttp.nonProxyHosts=localhost,127.0.0.1,*.whatever.com -Dhttp.proxyHost=<proxy address> -Dhttp.proxyPort=<proxy port>
4545
EOM
4646
source ~/.bashrc
4747
```

dockerizeit/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ services:
88
- http_proxy
99
- https_proxy
1010
- no_proxy
11-
- JAVA_OPTS
11+
- JAVA_PROXY
1212
restart: unless-stopped
1313
logging:
1414
driver: "json-file"

dockerizeit/master/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ FROM jenkins:2.46.3-alpine
66
ENV http_proxy ${http_proxy:-}
77
ENV https_proxy ${https_proxy:-}
88
ENV no_proxy ${no_proxy:-}
9-
ARG JAVA_OPTS
10-
ENV JAVA_OPTS "-Djenkins.install.runSetupWizard=false ${JAVA_OPTS:-}"
9+
ARG JAVA_PROXY
10+
ENV JAVA_PROXY ${JAVA_PROXY:-}
11+
ENV JAVA_OPTS "-Djenkins.install.runSetupWizard=false ${JAVA_PROXY:-}"
1112

1213
# Define build argument and env variable master_image_version
1314
# Use to pass info about Jenkins version so it can be represented

dockerizeit/master/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ gerrit {
308308
### Proxy
309309

310310
Configured by the [proxy.groovy](proxy.groovy)
311-
The script will read http_proxy, https_proxy, no_proxy, JAVA_OPTS environment variables (set during the container build. See [Dockerfile](Dockerfile) for more details) and define then as Jenkins global variables.
311+
The script will read http_proxy, https_proxy, no_proxy, JAVA_PROXY environment variables (set during the container build. See [Dockerfile](Dockerfile) for more details) and define then as Jenkins global variables.
312312

313313
### Security configuration
314314

dockerizeit/master/proxy.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def helpers = shell.parse(new File("/var/jenkins_home/init.groovy.d/helpers.groo
99
println "--> Setting up proxy"
1010

1111
def gradle_opts = ""
12-
def proxy_vars = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'JAVA_OPTS']
12+
def proxy_vars = ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'JAVA_PROXY']
1313
for (e in System.getenv()) {
1414
def key = e.key.toUpperCase()
1515
if ( ! proxy_vars.contains(key) ) {

jobdsl-gradle/src/jobs/resources/pipelines/jenkinsdeploy.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ node(env.utility_slave) {
1515

1616
stage('Build master Docker image') {
1717
// docker pipeline plugin build command does not implement to take arguments yet
18-
sh 'cd dockerizeit/master && docker build --build-arg master_image_version=${master_image_name}:$(git describe --tags) --build-arg http_proxy --build-arg https_proxy --build-arg no_proxy --build-arg JAVA_OPTS -t ${master_image_name}:$(git describe --tags) .'
18+
sh 'cd dockerizeit/master && docker build --build-arg master_image_version=${master_image_name}:$(git describe --tags) --build-arg http_proxy --build-arg https_proxy --build-arg no_proxy --build-arg JAVA_PROXY -t ${master_image_name}:$(git describe --tags) .'
1919
}
2020

2121
// This have to be outside of stages to be available for other stages

0 commit comments

Comments
 (0)