Open MPV opened 6 years ago
I'd probably try adding scripts in /docker-entrypoint.d
and see if that works as expected? See https://github.com/gocd/docker-gocd-agent/blob/2b25324f1b16bf41ebafc607e929a379d6562d45/docker-entrypoint.sh.erb#L113-L124
Oh maybe I've interpreted it wrong... I thought /docker-entrypoint.d
was only run as root?
I want my scripts to be run as the go
user (to be set for pipeline jobs).
I thought this line made it run /goagent/agent.sh
as the go user, using gosu
:
...but maybe it's running itself again and thus loading /docker-entrypoint.d/
files, also as go
?
This is what led me to configure the /etc/default/go-agent
file from before:
Users can override default startup arguments for a GoCD agent in a Linux machine by editing the file etc/default/go-agent.
@ketan Looking at the logs of my container, I see this happening during startup:
/docker-entrypoint.sh: Creating directories and symlinks to hold GoCD configuration, data, and logs
[...]
$ chown go:go /go/config/autoregister.properties
/docker-entrypoint.sh: Running custom scripts in /docker-entrypoint.d/ ...
$ exec /usr/local/sbin/tini -- /usr/local/sbin/gosu go /docker-entrypoint.sh /go-agent/agent.sh
/docker-entrypoint.sh: line 57: /usr/local/bin/nohup.out: Permission denied
$ exec /go-agent/agent.sh
[Thu Sep 06 11:18:35 GMT 2018] Starting process:
[...]
...thus it doesn't seem like it runs those files in /docker-entrypoint.d
as go
, but only as root
?
Any suggestions of what I could try?
@MPV
Here's how things have been designed:
/docker-entrypoint.d
executes as root
user, intentionally so. Use this to provision, install packages etc./etc/default/go-agent
is sourced from the agent startup script (/goagent/agent.sh
). Use this to ensure that variables are available to the agent process (which runs as the go
user). This file can be volume mounted (or baked into the image, as the case may be).
What I'd like to do: Run scripts that set environment variables, which become available to my agents.
Steps I've done:
gocd/gocd-agent-docker-dind
specifically)./etc/profile.d/
, for example this one:export PATH="/home/go/.local/bin:$PATH"
/etc/profile
in turn should load the files in/etc/profile.d
:...however when I run jobs using this image, my scripts haven't been run, and the environment variables aren't set.
Questions:
/etc/default/go-agent
)Am I running without
service_mode
? I suppose I am (?) — and then my guess (judging from/go-agent/agent.sh
) is that maybe my file won't be loaded: