Hi,
I am new to Buildkite.
I’m trying to checkout my docs repo in Buildkite and install Python.
My next steps in buildkite would be to install mkdocs and run mkdocs gh-deploy
.
I am trying to run all these steps into a single job using Python docker image but it launches a Python shell in the container and the jobs run until infinity.
Can someone please explain what am I doing incorrectly here?
Thanks.
steps:
- label: ":shrek: Deploy docs"
key: "mkdocs-deploy-docs"
plugins:
- docker#v5.9.0:
image: "python"
commands: |
#!/bin/bash
echo --- Installing dependencies
pip install -r requirements.txt
mkdocs gh-deploy
Hey @fansari1
Welcome to the Buildkite Community forums!
Thanks for reaching out about running commands using a Python container image.
With the Docker plugin there are two ways in which commands can be run in the container itself, using the command
attribute on the Step or in the command
parameter in the Plugin config but they are run differently.
What you can do is put the commands in the command
attribute of the Step instead e.g.,
steps:
- label: ":shrek: Deploy docs"
key: "mkdocs-deploy-docs"
commands: |
echo --- Installing dependencies
pip install -r requirements.txt
mkdocs gh-deploy
plugins:
- docker#v5.9.0:
image: "python"
The reason for this is whilst using the Plugin, the commands from the Step get translated into the docker run command to run the container using a shell e.g.,
python /bin/sh -e -c $'echo --- Installing dependencies\npip install -r requirements.txt\nmkdocs gh-deploy\n'
This then overrides the entrypoint in the image, which for the Python image is the python shell.
Alternative you could use the command
parameter in the Plugin config, but this needs to be an array e.g., [ "/bin/mycommand", "-c", "test" ]
and this requires specifying which binary to use e.g., /bin/sh
instead, followed by arguements.
More details on that here:
Hope that helps, but let us know.
Cheers,
Tom
Thanks a lot @tomwatt !!
I was able to run the commands as I intended to.
2 Likes