Closed ghost closed 1 year ago
Can you elaborate on what the problem is you're trying to solve with customised wrapper configuration within entrypoints, or what you are trying to achieve in general?
I believe this might have been somewhat intentional to bring confidence that the parameters don't clash (which causes weird behaviour), and general hope that folks could use the special environment variables to manage most aspects, rather than having to touch the wrapper properties.
On the other hand, given the server one is different, perhaps it is unintentional and there might be little downside to changing it - as long as people aren't mounting volumes to /go-agent/wrapper-config
.
Actually, the reason is most likely because the container image out-of-the-box already contains the below (similar to the non-container installers), so the intent is to wipe the contents out when using the "opinionated" entrypoint. The server one doesn't have any un-commented properties in its default template, so there is probably less concern with doing that.
If it were to append, it'd be appending to this file which would probably be confusing. But there might be other approaches to achieve the same thing.
[go@66141df46ab7 /]$ cat /go-agent/wrapper-config/wrapper-properties.conf
#encoding=UTF-8
# First line specifies encoding, see https://wrapper.tanukisoftware.com/doc/english/props-directives.html
# Use this file to configure your GoCD agent
# Set any system properties. We recommend that you begin with the index `100` and increment the index for each system property
# setup the GoCD server URL
wrapper.app.parameter.100=-serverUrl
wrapper.app.parameter.101=http://localhost:8153/go
#encoding=UTF-8
# First line specifies encoding, see https://wrapper.tanukisoftware.com/doc/english/props-directives.html
# For a detailed description about setting various environment variables, see the page at
# https://wrapper.tanukisoftware.com/doc/english/props-envvars.html
# For a detailed description about setting JVM options and system properties, see the page at
# https://wrapper.tanukisoftware.com/doc/english/props-jvm.html
# To understand how properties can be overridden in this file, see the page at:
# https://wrapper.tanukisoftware.com/doc/english/props-cascading.html
# To use a custom JVM:
# wrapper.java.command=/path/to/java
# To set any environment variables of your choice use the following syntax
#set.SOME_ENVIRONMENT_VARIABLE=some-value
#set.GRADLE_HOME=/path/to/gradle
#set.M2_HOME=C:\apache-maven-3.2.1
#set.MAVEN_OPTS=-Xmx1048m -Xms256m -XX:MaxPermSize=312M
# Appending to existing environment variables:
# This config supports environment variable expansion at run time within the values of any environment variable.
# To maintain the platform independent nature of this configuration file, the Windows syntax is used for all platforms.
# On windows:
#set.PATH=..\lib;%PATH%
# On Unix/Linux/macOS. Note that you must use %PATH%, and not $PATH, as you'd normally do on this platform
#set.PATH=../lib:%PATH%
###### System properties for GoCD agent bootstrapper ######
# Set any system properties. We recommend that you begin with the index `100` and increment the index for each system property
#wrapper.java.additional.100=-Dcom.example.enabled=true
#wrapper.java.additional.101=-Dcom.example.name=bob
# If a property contains quotes, these can be stripped out, but this works only on Unix/Linux/macOS
#wrapper.java.additional.103=-Dmyapp.data="../MyApp Home"
#wrapper.java.additional.104.stripquotes=TRUE
###### System properties for GoCD agent ######
# Set a memory limit of 1GB for the agent process. We recommend that you do not use more than half your system memory.
#set.AGENT_STARTUP_ARGS=-Xms128m -Xmx1024m -Dsome.java.property=somevalue
@chadlwilson , thank you for the quick response!
Basically I like to extend the PATH parameter and the wrapper-properties.conf seemed to be the natural/only place for this. It worked fine on the server and I expected parity with the agent version but was stumbling over the difference in the entry point wiping out any changes done during docker build.
The only part from the template wrapper-properties.conf, which are not commented, are the serverUrl & Value, it may make more sense to simply overwrite them instead of wiping the whole content (or put it into the wrapper call as this seems to override the config settings, when remembering correctly what the Tanuki docs say about this), so server and agent would behave similar but you still have no side effects by the existing entries.
For the moment I just changed the replacing part which results in duplicate serverUrl entries, what still works, seems last one wins, but maybe just for the moment, ...
Fixing that or have another option to adjust the Tanuki internal PATH would be way cleaner.
Best, Peter
Basically I like to extend the PATH parameter and the wrapper-properties.conf seemed to be the natural/only place for this ... Fixing that or have another option to adjust the Tanuki internal PATH would be way cleaner.
Ahh. Your entrypoint is trying to dynamically install something and add it to the PATH
or something like that, and you want it to be available to agent jobs when they run without using full paths in tasks?
In the short term, if you don't mind overriding the entire path (and the slight coupling that brings) you could do it externally from docker/kubernetes via an env var, similar to -e PATH=/my-folder:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
or symlink/copy your tool onto the existing default path. Tanuki should pick that up.
Alternatively build your own child image that extends the GoCD ones and do things in RUN
and ENV
commands rather than relying on entrypoints at start time.
Hi, thx for the suggestions!
To be clear on this I'm not relying on the docker-entrypoint.sh per-se I adjust the wrapper-properties.conf, the entry-point just wipes that later on, ...
Hm, tried to be not that intrusive overwriting the complete PATH, but adding it via Alpine internals like profile.d happens too late/login only, so Tanuki is ignoring this. Overwriting would be the only option then via ENV, sad that we can't utilise the Tanuki config to do that ,...
I'd go rather with full paths instead of overwriting the complete PATH.
Feel free to close the issue, if there is no chance to handle server/agent the same way, or make the wrapper-properties.conf adjustable.
I'll probably change it per your suggestion, just need to think through the consequences for consistency with the non docker images and possible accidental regressions for folks.
Was just trying to give you a short term workaround to achieve what you want 👍
https://github.com/gocd/gocd/blob/de940cb3d466aff747b5dc2708da25d8e8f5cf67/buildSrc/src/main/resources/gocd-docker-agent/docker-entrypoint.sh#L134
In the docker entrypoint of the gocd-agent, in line 134 everything that was added to this file gets wiped by using > instead of >> like in the server version of the docker-entrypoint.
As the loop over docker-entry point.d is happening just a few lines above that section it does negate every change that have been done to adjust this file.