Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run teamcity agent under buildagent user using gosu, fixes #16 #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

antonbormotov
Copy link

No description provided.

@antonbormotov
Copy link
Author

antonbormotov commented May 3, 2018

@VladRassokhin, @redhandpl, @omar-a-toma would you mind to review please

@antonbormotov antonbormotov force-pushed the run-agent-under-agent-user branch 4 times, most recently from 3849621 to 05f389b Compare May 3, 2018 05:48
@antonbormotov antonbormotov changed the title Run teamcity agent as buildagent Run teamcity agent as buildagent, fixes #16 May 3, 2018
@@ -66,7 +66,7 @@ else
prepare_conf
fi

${AGENT_DIST}/bin/agent.sh start
gosu buildagent ${AGENT_DIST}/bin/agent.sh start

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider chown for buildagent user during 'initialization' (in addition to the Dockerfile), either:
A) in this entrypoint
B) As an entry in /services/

    chown -R buildagent:buildagent /opt/buildagent

Otherwise this may break for users of jetbrains/teamcity-agent which run "Docker from the host". The permissions need to be set at container 'runtime' since the checkout dir and temp dir are bind-mount VOLUMEs; as explained here: https://hub.docker.com/r/jetbrains/teamcity-agent/

Options -v /opt/buildagent/work:/opt/buildagent/work and -v /opt/buildagent/temp:/opt/buildagent/temp are required if you want to use Docker Wrapper on this build agent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -14,6 +14,19 @@ COPY dist/buildagent /opt/buildagent
RUN useradd -m buildagent && \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stayclassychicago @yaegor user buildagent must be part of docker group in teamcity-docker-agent container in order to be able to run dockerized tasks.
Shall we run usermod -a -G docker buildagent there?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, we can create docker group in advance here, and add buildagent user to this group.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think either is necessary for this minimal agent image. The teamcity-docker-agent provisions both:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I missed that

&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
Copy link

@stayclassychicago stayclassychicago May 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this step still work for you? This fails with keyserver communications error (below). Not sure if this is a regional issue (if so are there mirrors for this keyserver) or if you are able to validate this is still successful ?

gpg: keyserver communications error: keyserver unreachable
?: [fd 4]: read error: Connection reset by peer
gpgkeys: HTTP fetch error 7: couldn't connect: eof
gpg: keyserver communications error: public key not found
gpg: keyserver receive failed: public key not found

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it does for me, let me check if ubuntu apt key servers have this key.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cold you please check if following works for you:

  1. gpg --keyserver keyserver.ubuntu.com --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
  2. apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4

It is weird, that it can't connect; keyserver.ubuntu.com is part of sks pool as well.
Are you able to resolve domain dig +short ha.pool.sks-keyservers.net?

@antonbormotov
Copy link
Author

@VladRassokhin could you please review this pr, if you have some free time, of course.

@VladRassokhin
Copy link
Contributor

Currently we're preparing TeamCity 2018.1 release so I don't have spare time to take a look. Probably a month later we would evaluate this PR.

@kir
Copy link
Member

kir commented Dec 29, 2018

Hello,

I've just pushed a fix for #16 which optionally runs agent under buildagent user when -e RUN_AS_BUILDAGENT=true is passed to the docker run.

Please let me know if there are any issues with the fix.

Thank you!

@antonbormotov antonbormotov changed the title Run teamcity agent as buildagent, fixes #16 Run teamcity agent under buildagent user using gosu, fixes #16 Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants