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.
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--
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.