Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom init scripts in bamboo-agent-base docker image

Jens Rutschmann [K15t]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2023

Hi,

I'd like to run a custom initialization script in my remote agent's docker container at startup time.

The goal is to define an agent capability value that cannot be determined at the time the image is built -> I can't just invoke bamboo-update-capability.sh in the Dockerfile.

The docker image for the agent is based on https://hub.docker.com/r/atlassian/bamboo-agent-base, which has been built for extensibility, but unfortunately doesn't provide a way to do what I want.

Ideally the entrypoint script could check a folder for custom scripts and then just execute them, similar to what other popular images like the postgres image do (see section 'Initialization scripts', entrypoint script source).

With something like this in place I could just copy my custom script via my Dockerfile and then the standard entrypoint script would run it before it starts the agent process, for example:

COPY custom-init.sh /docker-entrypoint-initagent.d/

 

Currently the only way to achieve something like this would be to replace either pre-launch.sh or entrypoint.py, which is bad because I'd need to manually copy the content from the original files whenever I build a new image version.

2 answers

2 votes
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 7, 2023

Hello @Jens Rutschmann [K15t]

You can create a custom-entrypoint.sh script that will run the code you need then launch pre-launch.sh:

#!/bin/bash
echo Hello World!!!
echo You could now be doing something funny as creating a custom capabilities file!

echo Sleeping for 5 seconds before invoking the real thing...

sleep 5

/pre-launch.sh $@

Then in your Dockerfile you can do something like this:

FROM atlassian/bamboo-agent-base:latest

COPY --chmod=700 --chown=root:root custom-entrypoint.sh /

ENTRYPOINT ["/custom-entrypoint.sh"]

CMD ["/usr/bin/tini", "-s", "--", "/entrypoint.py"]

And build your image like this:

docker build -t local/bamboo-agent-base-custom:latest --no-cache -f Dockerfile .

Cheers,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

1 vote
Jens Rutschmann [K15t]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2023

Hey @Eduardo Alvarenga thanks so much for the quick response.

Your approach is definitively much better than overwriting the original prelaunch script. Should have thought about this myself.

Still this would break if Atlassian changes the original ENTRYPOINT value (script name / parameters) in the base image's Dockerfile, so introducing an init scripts folder as suggested might still be a valid improvement.

Would be great if this could be considered. In the meantime I'll overwrite the entrypoint as you suggested.

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events