Docker ¶
RunInContainerBaseTask ¶
-
inner_execute() should be used to execute a code while the container is running
-
execute() should not be overridden
Package to import |
Single task to import |
PIP package to install |
Stable version |
---|---|---|---|
pip install rkd== SELECT VERSION |
Caution
This is a Base Task. It is not a Task to run, but to create a own, runnable Task basing on it.
Hint
This is an extendable task. Read more in Extending tasks chapter.
- class rkd.core.standardlib.docker. RunInContainerBaseTask [source] ¶
-
# <sphinx:extending-tasks>
Allows to work inside of a temporary docker container.
Configuration:
-
mount(): Mount directories/files as volumes
-
add_file_to_copy(): Copy given files to container before container starts
-
user: Container username, defaults to “root”
-
shell: Shell binary path, defaults to “/bin/sh”
-
docker_image: Full docker image name with registry (optional), group, image name and tag
-
entrypoint: Entrypoint
-
command: Command to execute on entrypoint
Runtime:
-
copy_to_container(): Copy files/directory to container immediately
-
in_container(): Execute inside container
Example:
version: org.riotkit.rkd/yaml/v1 imports: - rkd.core.standardlib.docker.RunInContainerBaseTask tasks: :something-in-docker: extends: rkd.core.standardlib.docker.RunInContainerBaseTask configure: | self.docker_image = 'php:7.3' self.user = 'www-data' self.mount(local='./build', remote='/build') self.add_file_to_copy('build.php', '/build/build.php') inner_execute: | self.in_container('php build.php') return True # do not extend just "execute", because "execute" is used by RunInContainerBaseTask # to spawn docker container, run inner_execute(), and after just destroy the container
# </sphinx:extending-tasks>
- add_file_to_copy ( local : str , remote : str ) None [source] ¶
-
Schedules a file to be copied during execution time
- Parameters
-
-
local –
-
remote –
-
- Returns
-
- copy_to_container ( local : str , remote : str ) None [source] ¶
-
Copies a file from host to container Can be used on execute stage
- Api
-
- Parameters
-
-
local –
-
remote –
-
- Returns
-
- execute ( context : rkd.core.api.contract.ExecutionContext ) bool [source] ¶
-
Executes a task. True/False should be returned as return
-